/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.crm.controller;

import java.sql.SQLException;
import java.text.ParseException;
import java.util.ArrayList;
import org.apache.log4j.Logger;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;

import javax.faces.model.SelectItem;
import queenb.net.entitybean.N100;
import queenb.net.entitybean.N550;
import queenb.net.entitybean.Q400;
import queenb.net.entitybean.V500;
import queenb.web.controller.QueenbController;
import queenb.web.controller.SearchController;
import queenb.web.crm.inteface.CustomerInf;
import queenb.web.crm.inteface.N900Inf;
import queenb.web.crm.store.CustomerStore;
import queenb.web.crm.store.K400Store;
import queenb.web.crm.store.N900Store;
import queenb.web.crm.store.V030Store;
import queenb.web.store.ContactStore;
import queenb.web.store.EmployeeStore;
import queenb.web.store.N550Store;
import queenb.web.store.V500Store;
import queenb.web.util.ComboboxUtil;
import queenb.web.util.ContextUtil;
import queenb.web.util.SessionProvider;
import queenb.web.util.Util;

/**
 *
 * @author Nguyen Hung
 */
public class CustomerController extends QueenbController {

    private static Logger logger = Logger.getLogger(CustomerController.class);
    private int pn100;// ID Khach Hang
    private int fn600;// Phan biet khach hang voi nhan vien
    private int fk100 = 442;//
    private int fh200;// thuoc cong ty
    private String nv102 = "NONAME";//Ho
    private String nv103;//Ten
    private String nv127;// chu lot
    private String nv129;// chu lot
    private String nv107 = "M";//Gioi Tinh    
    private String nv108;// Title
    private String nv109;//Tinh trang gia dinh
    private Date nd118;//ngay sinh
    private String date_nd118;
    private String nv110;//department
    private String nv111;//chuc vu
    private String nv113;//nguoi chiu trach nhiem
    private String nv123;// noi sinh
    // private String nv116;//nguoi gioi thieu;
    private String nv112;//nguoi gioi thieu
    private String nv962;//email
    private String nv958;//mobi
    private String nv967;//tel
    private String nv119;//
    private int nn117;// danh dau nguoi dai dien  (= 0 nguoi dai dien)
    private int fn850;
    private int fn850gt;//fn nguoi gioi thieu
    private boolean show1;
    private boolean show2;
    private String old;//tuoi
    private int fn550;//nganh nghe  
    private int ni104 = 1;//khach hang tiem nang
    private int ni105;
    private List<N100> listN100 = null;
    private List<N100> listpersion = new ArrayList<N100>(); // danh sach nguoi dai dien
    private List<N100> listFindCustomer = null;
    private List<N100> listemp = new ArrayList<N100>();
    private String charSearch = "";
    private CustomerInf customerInf;
    private boolean flag;
    private String idSearch;
    private List<SelectItem> selectItemsN550;
    private List<SelectItem> selectItemN900 = new ArrayList<SelectItem>();
    private List<SelectItem> selectCombN850 = new ArrayList<SelectItem>();
    private CustomerStore customerStore = new CustomerStore();
    private N900Store n900Store = new N900Store();
    private N900Inf n900Inf;
    private String sendPage;//
    ComboboxUtil comboboxUtil = new ComboboxUtil();
    private int FN600 = 2;
    private int beginContructor;
    private List<N100> listCustomerForDay = new ArrayList<N100>();
    private String pagereload;
    private int typeSearch;
    private String keySearch;
    private List<SelectItem> listGroup = new ArrayList<SelectItem>();
    private List<N100> listSelected = new ArrayList<N100>();
    private int groupID = 0;
    private List<Q400> listQ400;
    private String message;
    private String editpage;//Danh dau edit de load ajax cho cac trang khi edit mot khach hang
    private String messagefrom;
    private String nv130;
    private List<SelectItem> listComboK300 = new ArrayList<SelectItem>();
    private List<SelectItem> listComboK330 = new ArrayList<SelectItem>();
    private int FK300 = 1;// id nguồn thông tin
    private int FK330 = 1;// id status
    private int fk400 = 0;
    //paging
    private int Offset = 0;
    private int Limit = 30;
    private int totalrow; // tong so dong
    private int totalpage; // tong so trang
    private int current; // traung hien tai
    static private int numrow = 30; // so dong tren 1 trang
    private int start; // bat dau lay tu record
    private int end; // lay tu record so
    private int startpage = 1; // page bat dau
    private int endpage = 1;   // page ket thuc
    private String pagename = "";
    private int totalcurent;
    private int typesearchcurent;
    private int tip = 0;
    private String nv961;//mobi 1
    private String hoten;
    private int choisetab;//Dieu khien tab xo xuong trong danh sanh nhan vien - nguoi dai dien trong cong ty
    private String mv306;
    private String urlMD5;
    private String empString;//kiem tra acion redirect ve trang khi dong popupup sms
    private List<N100> listdifn100;
    private String keysearchKH;
    private int typesearchKH;
    // Add mobi tel email,notice
    private String tel;
    private String email;
    private String mobi;
    private String notice;
    private List<N100> list = new ArrayList<N100>();
    private List<Q400> listQ400S = new ArrayList<Q400>();
    private List<V500> listV500;
    private int fk100down;// id khi clik vao ten de so xuong
    private int dayss;
    private int flagForm;
    private List<SelectItem> lstEmpByID = new ArrayList<SelectItem>();
    private String loginEmp;
    private String userAction;
    private int flagFN850;
    // gui Email vs SMS
    private List<N100> listSelectedNV = new ArrayList<N100>();// dnah sach addd vao 
    private List<N100> listSelectedDD = new ArrayList<N100>();
    private List<N100> listSelectedNVout = new ArrayList<N100>();// lay danh sahc ra
    private List<N100> listSelectedDDout = new ArrayList<N100>();
    private int chooseformepmloyee;// khi edit thi tra laij list All cho cong ty 
    private int idListTour;// Phaan bieet button close form them khach ahng
    private int FV050EE;// neu > 0 thi se insert nguoi vao Tour luon
    private int close;// phan biet button Close
    private Date startDateSta;// ngay status
    private Date endDateSta;// ngay het thuc
    private Date dateStatus;// ngay du kien tham gia
    private int idmobiSAVE;// phân biệt luu mobi
    private int passwordSMS;// phai co pass de gui sms
    private String tabString = "TABLL";// phan biet cac tab 

    public CustomerController() throws ParseException {
        if (SessionProvider.getSessionMapValue("groupID") != null) {
            fn850 = Integer.parseInt(SessionProvider.getSessionMapValue("groupID").toString());
        }
        try {
            if (SessionProvider.getSessionMapValue("emp") != null) {
                loginEmp = SessionProvider.getSessionMapValue("emp").toString();
                userAction = loginEmp;
            }
        } catch (Exception e) {
        }

        Object listselect1 = SessionProvider.getSessionMapValue(getKapiMenu().getListSelectedEx());


        if (listselect1 == null) {
            //SessionProvider.setSessionMapValue("listSelectedEx", listSelected);
            SessionProvider.setSessionMapValue(getKapiMenu().getListSelectedEx(), listSelected);

        } else {
            try {
                listSelected = (List<N100>) listselect1;
            } catch (Exception e) {
                listSelected = new ArrayList<N100>();
            }
        }
        if (listselect1 != null) {
        }
        Object listBean1 = SessionProvider.getSessionMapValue("LISTN100CUSSS");
        if (listBean1 == null) {
            SessionProvider.setSessionMapValue("LISTN100CUSSS", listN100);
        } else {
            try {
                listN100 = (List<N100>) listBean1;
            } catch (Exception e) {
                listN100 = new ArrayList<N100>();
            }
        }
        System.out.println("CustomerController--fn850--" + fn850 + "--emplogin---" + loginEmp);
        getKapiMenu().setMd5url(getRequest().getRequestURI());
        System.out.println("----------md5---------4-" + getKapiMenu().getMd5url() + "---" + getRequest().getRequestURI());
        SearchController searchController = new SearchController();
        idSearch = searchController.searchAlpha_KHCN();
        searchAlphaCustomer();


        try {
            Object typeObject = ContextUtil.getRequestParameter("type");
            if (typeObject.equals("1")) {
                this.ni104 = 0;
            } else if (typeObject.equals("0")) {
                this.ni104 = 1;
            }


            Object objbirday = ContextUtil.getRequestParameter("leavedate1");
            if (objbirday != null) {
                this.nd118 = Util.parseDate(objbirday.toString(), "dd/MM/yyyy");
            }

            this.pagereload = getRequest().getParameter("page");
            if (this.pagereload == null) {
                this.pagereload = ContextUtil.getRequestParameter("page");
            }
            //this.pagereload = pages.toString();
            System.out.println("**************************" + pagereload);
            Object objPK400 = getRequest().getParameter("pk400");
            if (objPK400 != null) {
                fk400 = Integer.parseInt(objPK400.toString());
            }

            Object type = getRequest().getParameter("type");
            if (type != null) {
                ni104 = Integer.parseInt(type.toString());
                SessionProvider.setSessionMapValue("customertype", ni104);
            }
            Object objNN117 = getRequest().getParameter("nn117");
            if (objNN117 != null) {
                this.nn117 = Integer.parseInt(objNN117.toString());
            }

        } catch (Exception ex) {
        }


        getKapiMenu().setAdmin(false);
        getKapiMenu().setMainmenu1("m121");
        String tab = "s3" + (getNi104() + 1);
        getKapiMenu().setSubmenu3(tab);


        Object objDayss = getRequest().getParameter("dayss");
        if (objDayss != null) {
            dayss = Integer.parseInt(objDayss.toString());
        }
        Object objChosetab = getRequest().getParameter("choisetab");
        if (objChosetab != null) {
            this.choisetab = Integer.parseInt(objChosetab.toString());
            getKapiMenu().setChoisetab(choisetab);
        }
        Object objflagForm = getRequest().getParameter("flagform");
        if (objflagForm != null) {
            flagForm = Integer.parseInt(objflagForm.toString());
            getKapiMenu().setFlagform(flagForm);
        }
        Object pnPN100 = getRequest().getParameter("pnPN100");
        if (pnPN100 != null) {
            pn100 = Integer.parseInt(pnPN100.toString());
            SessionProvider.setSessionMapValue("groupcustomerID", 0);
            //SessionProvider.setSessionMapValue("customertype", 0);
            // getLogin().setCharacter(null);
        }
//  Get param pn100 dung chung cho moi action lay ve
        Object objPN100 = getRequest().getParameter("pn100");
        if (objPN100 != null) {
            this.pn100 = Integer.parseInt(objPN100.toString());
        }

        Object objectValue = getRequest().getParameter("typecheck");
        if (objectValue != null) {
            if (objectValue.equals("NV")) {

                Object listselect = SessionProvider.getSessionMapValue("listPersonalDSVN");
                System.out.println("-----xem null ko ----" + listselect);
                if (listselect == null) {
                    //SessionProvider.setSessionMapValue("listSelectedEx", listSelected);
                    SessionProvider.setSessionMapValue("listPersonalDSVN", listSelectedNV);
                } else {
                    try {
                        listSelectedNV = (List<N100>) listselect;
                    } catch (Exception e) {
                        listSelectedNV = new ArrayList<N100>();
                    }
                }
                if (listselect != null) {
                    System.out.println("-----list select ----" + listSelectedNV.size());
                }

                Object listBean = SessionProvider.getSessionMapValue("listPersonalSystem");
                if (listBean == null) {
                    SessionProvider.setSessionMapValue("listPersonalSystem", listSelectedNVout);
                } else {
                    try {
                        System.out.println("----------System-------- " + listSelectedNVout.size());
                        listSelectedNVout = (List<N100>) listBean;
                    } catch (Exception e) {
                        listSelectedNVout = new ArrayList<N100>();
                    }
                }
            } else if (objectValue.equals("DD")) {
                Object listselect = SessionProvider.getSessionMapValue("listPersonalDSDD");
                if (listselect == null) {
                    //SessionProvider.setSessionMapValue("listSelectedEx", listSelected);
                    SessionProvider.setSessionMapValue("listPersonalDSDD", listSelectedDD);
                } else {
                    try {
                        listSelectedDD = (List<N100>) listselect;
                    } catch (Exception e) {
                        listSelectedDD = new ArrayList<N100>();
                    }
                }
                if (listselect != null) {
                    System.out.println("-----list select ----" + listSelectedDD.size());
                }

                Object listBean = SessionProvider.getSessionMapValue("listPersonalSystemDD");
                if (listBean == null) {
                    SessionProvider.setSessionMapValue("listPersonalSystemDD", listSelectedDDout);
                } else {
                    try {
                        System.out.println("----------System-------- " + listSelectedDDout.size());
                        listSelectedDDout = (List<N100>) listBean;
                    } catch (Exception e) {
                        listSelectedDDout = new ArrayList<N100>();
                    }
                }
            }
        }
        Object action = getRequest().getParameter("action");
        if (action != null) {
            if (action.equals("delSessionlistcheckAll")) {
                if (SessionProvider.getSessionMapValue("listPersonalDSVN") != null) {
                    SessionProvider.removeSessionMapValue("listPersonalDSVN");
                }
                if (SessionProvider.getSessionMapValue("listPersonalDSDD") != null) {
                    SessionProvider.removeSessionMapValue("listPersonalDSDD");
                }

                if (SessionProvider.getSessionMapValue("listSelected") != null) {
                    SessionProvider.removeSessionMapValue("listSelected");
                }

                if (SessionProvider.getSessionMapValue("listSelectedEx") != null) {
                    SessionProvider.removeSessionMapValue("listSelectedEx");
                }
            } else if (action.equals("getitemvaluePn100")) {
                Object Objectidk100 = getRequest().getParameter("pn100");
                if (Objectidk100 != null) {
                    pn100 = Util.parseInt(Objectidk100);
                    System.out.println("----------------------ID CUA CUSTOMER WHEN CLICK VAO-------------" + pn100);
                    SessionProvider.setSessionMapValue("PN100HD", pn100);
                }
                if (SessionProvider.getSessionMapValue("listPersonalDSVN") != null) {
                    SessionProvider.removeSessionMapValue("listPersonalDSVN");
                }
                if (SessionProvider.getSessionMapValue("listPersonalDSDD") != null) {
                    SessionProvider.removeSessionMapValue("listPersonalDSDD");
                }
            } else if (action.toString().equals("addEmp")) {
                if (SessionProvider.getSessionMapValue("PN100HD") != null) {
                    SessionProvider.removeSessionMapValue("pn100HD");
                }
                Object idObject = getRequest().getParameter("id");
                Object stepObject = getRequest().getParameter("step");
                // insert người đại diện và nhân viên của công ty
                Object Objectidk100 = getRequest().getParameter("idk100");
                if (Objectidk100 != null) {
                    fk100 = Util.parseInt(Objectidk100);

                }
                Object ObjectClose = getRequest().getParameter("close");
                if (ObjectClose != null) {
                    close = Util.parseInt(ObjectClose);

                }
                if (idObject != null) {
                    pn100 = Util.parseInt(idObject);

                }
                if (stepObject != null && stepObject.toString().equals("persion")) {
                    tip = 1;
                } else {
                    tip = 0;
                }
                flag = false;
                setNn117(1);
                setNi104(0);
                SessionProvider.setSessionMapValue("NI104UP", 0);// mac dinh la time nang
                if (SessionProvider.getSessionMapValue("IDSAVEC") != null) {
                    SessionProvider.removeSessionMapValue("IDSAVEC");
                    System.out.println("-----------XOA ISDSA-----" + SessionProvider.getSessionMapValue("IDSAVEC"));
                }
            } else if (action.equals("addpersonalDDforTour")) {
                Object objectFV050 = getRequest().getParameter("FV050");
                Object objectPage = getRequest().getParameter("step");
                if (objectFV050 != null) {
                    // fk100 thay bang fv050
                    fk400 = Util.parseInt(objectFV050);
                }
                if (objectPage != null) {
                    // fk100 thay bang fv050
                    idListTour = Util.parseInt(objectPage);
                }
            } else if (action.toString().equals("addnotcheckAll")) {
                if (SessionProvider.getSessionMapValue("listSelected") != null) {
                    SessionProvider.removeSessionMapValue("listSelected");
                }
                Object objectNV = getRequest().getParameter("typecheck");
                if (objectNV.equals("NV")) {
                    Object personal = getRequest().getParameter("pn100");
                    Object valueBoolen = getRequest().getParameter("boolNV");

                    System.out.println("------Gia tri---------------------" + personal + "===============" + valueBoolen);
                    if ("false".equals(valueBoolen.toString())) {
                        for (int i = 0; i < listSelectedNV.size(); i++) {
                            if (listSelectedNV.get(i).getPn100() == Integer.parseInt(personal.toString())) {
                                listSelectedNV.remove(i);

                                System.out.println("------- List sau khi xoa---" + listSelectedNV.size());
                                break;
                            }
                        }
                    } else {
                        Object idofComCurrent = getRequest().getParameter("fk100CTT");
                        if (idofComCurrent != null) {
                            fk100 = Util.parseInt(idofComCurrent);
                            System.out.println("-----" + fk100);
                            CustomerStore store = new CustomerStore();
                            listSelectedNVout = store.getListCustomerCompany(getLogin().getModule(), getLogin().getCompanyNo(), 0, fk100, 1, getLogin().getUserName());
                            System.out.println("------- list cua he thong---" + listSelectedNVout.size());
                        }

                        for (int i = 0; i < listSelectedNVout.size(); i++) {
                            if (listSelectedNVout.get(i).getPn100() == Integer.parseInt(personal.toString())) {
//                            if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                                if (!checkExistList(listSelectedNV, Integer.parseInt(personal.toString()))) {
                                    listSelectedNV.add(listSelectedNVout.get(i));
                                    break;
                                }

//                            }
                            }
                        }
                    }
                    SessionProvider.setSessionMapValue("listPersonalDSVN", listSelectedNV);
                    SessionProvider.setSessionMapValue("listPersonalSystem", listSelectedNVout);
                    System.out.println("<><><><><><><><><>AAAAAAAAAAAAAAAA<><><><><><><><><><>-----" + personal + "....." + listSelectedNV.size());
                } else if (objectNV.equals("DD")) {
                    if (SessionProvider.getSessionMapValue("listPersonalDSVN") != null) {
                        SessionProvider.removeSessionMapValue("listPersonalDSVN");
                    }
                    Object personal = getRequest().getParameter("pn100");
                    Object valueBoolen = getRequest().getParameter("boolNV");

                    System.out.println("------Gia tri---------------------" + personal + "===============" + valueBoolen);
                    if ("false".equals(valueBoolen.toString())) {
                        for (int i = 0; i < listSelectedDD.size(); i++) {
                            if (listSelectedDD.get(i).getPn100() == Integer.parseInt(personal.toString())) {
                                listSelectedDD.remove(i);

                                System.out.println("------- List sau khi xoa---" + listSelectedDD.size());
                                break;
                            }
                        }
                    } else {
                        Object idofComCurrent = getRequest().getParameter("fk100CTT");
                        if (idofComCurrent != null) {
                            fk100 = Util.parseInt(idofComCurrent);
                            System.out.println("-----" + fk100);
                            CustomerStore store = new CustomerStore();
                            listSelectedDDout = store.getListCustomerCompany(getLogin().getModule(), getLogin().getCompanyNo(), 0, fk100, 0, getLogin().getUserName());
                            System.out.println("------- list cua he thong---" + listSelectedNVout.size());
                        }

                        for (int i = 0; i < listSelectedDDout.size(); i++) {
                            if (listSelectedDDout.get(i).getPn100() == Integer.parseInt(personal.toString())) {
//                            if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                                if (!checkExistList(listSelectedDD, Integer.parseInt(personal.toString()))) {
                                    listSelectedDD.add(listSelectedDDout.get(i));
                                    break;
                                }

//                            }
                            }
                        }
                    }
                    SessionProvider.setSessionMapValue("listPersonalDSDD", listSelectedDD);
                    SessionProvider.setSessionMapValue("listPersonalSystemDD", listSelectedDDout);
                    System.out.println("<><><><><><><><><>DAI DIEN><><><><><><><><><>-----" + personal + "....." + listSelectedDD.size());
                }
            } else if (action.toString().equals("addcheckAll")) {
                if (SessionProvider.getSessionMapValue("listSelected") != null) {
                    SessionProvider.removeSessionMapValue("listSelected");
                }
                Object objectNV = getRequest().getParameter("typecheck");
                if (objectNV.equals("NV")) {
                    Object checktruefale = getRequest().getParameter("boolNV");
                    if ("true".equals(checktruefale.toString())) {
                        listSelectedNV.clear();
                        Object idofComCurrent = getRequest().getParameter("fk100CTT");
                        if (idofComCurrent != null) {
                            fk100 = Util.parseInt(idofComCurrent);
                            System.out.println("-----" + fk100);
                            CustomerStore store = new CustomerStore();
                            listSelectedNVout = store.getListCustomerCompany(getLogin().getModule(), getLogin().getCompanyNo(), 0, fk100, 1, getLogin().getUserName());
                            System.out.println("------- list cua he thong---" + listSelectedNVout.size());
                        }
                        for (int i = 0; i < listSelectedNVout.size(); i++) {
//                        if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                            listSelectedNV.add(listSelectedNVout.get(i));
//                        }
                        }
                    } else {
                        listSelectedNV.clear();
                    }
                    SessionProvider.setSessionMapValue("listPersonalDSVN", listSelectedNV);
                    SessionProvider.setSessionMapValue("listPersonalSystem", listSelectedNVout);

                    System.out.println("---------------- gai tri all-----------" + listSelectedNV.size() + listSelectedNVout.size());
                } else if (objectNV.equals("DD")) {
                    if (SessionProvider.getSessionMapValue("listPersonalDSVN") != null) {
                        SessionProvider.removeSessionMapValue("listPersonalDSVN");
                    }
                    Object checktruefale = getRequest().getParameter("boolNV");
                    if ("true".equals(checktruefale.toString())) {
                        listSelectedDD.clear();
                        Object idofComCurrent = getRequest().getParameter("fk100CTT");
                        if (idofComCurrent != null) {
                            fk100 = Util.parseInt(idofComCurrent);
                            System.out.println("-----" + fk100);
                            CustomerStore store = new CustomerStore();
                            listSelectedDDout = store.getListCustomerCompany(getLogin().getModule(), getLogin().getCompanyNo(), 0, fk100, 0, getLogin().getUserName());
                            System.out.println("------- list cua he thong---" + listSelectedDDout.size());
                        }
                        for (int i = 0; i < listSelectedDDout.size(); i++) {
//                        if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                            listSelectedDD.add(listSelectedDDout.get(i));
//                        }
                        }
                    } else {
                        listSelectedDD.clear();
                    }
                    SessionProvider.setSessionMapValue("listPersonalDSDD", listSelectedDD);
                    SessionProvider.setSessionMapValue("listPersonalSystemDD", listSelectedDDout);

                    System.out.println("---------------- gai tri all DDDDDDD-----------" + listSelectedDD.size() + listSelectedDDout.size());
                }


            } else if (action.equals("addCusp100")) {
                Object f = getRequest().getParameter("p100");
                Object s = getRequest().getParameter("valueC");


                if ("false".equals(s.toString())) {
                    for (int i = 0; i < listSelected.size(); i++) {
                        if (listSelected.get(i).pn100 == Integer.parseInt(f.toString())) {
                            listSelected.remove(i);
                            break;
                        }
                    }
                } else {
                    for (int i = 0; i < listN100.size(); i++) {
                        if (listN100.get(i).pn100 == Integer.parseInt(f.toString())) {
//                            if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                            listSelected.add(listN100.get(i));
                            break;
//                            }
                        }
                    }
                }
                List<N100> listgetrros = (List<N100>) listSelected;

                System.out.println("----------BAONHIEU ROW-------" + listgetrros.size());
                SessionProvider.setSessionMapValue("NUMBERPER", listgetrros.size());
                SessionProvider.setSessionMapValue("listSelectedEx", listSelected);
                SessionProvider.setSessionMapValue("listN100", listN100);

                //check All
            } else if (action.equals("addAllCusp100")) {
                Object va = getRequest().getParameter("boool");
                if ("true".equals(va.toString())) {
                    listSelected.clear();
                    for (int i = 0; i < listN100.size(); i++) {
//                        if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                        listSelected.add(listN100.get(i));
//                        }
                    }
                } else {
                    listSelected.clear();
                }
                List<N100> listgetrros = (List<N100>) listSelected;
                System.out.println("----------BAONHIEU ROW-------" + listgetrros.size());
                SessionProvider.setSessionMapValue("NUMBERPER", listgetrros.size());
                SessionProvider.setSessionMapValue("listSelectedEx", listSelected);
                SessionProvider.setSessionMapValue("listN100", listN100);
            } else if (action.toString().equals("reloadfordays")) {

                Object objflagFN850 = getRequest().getParameter("flagFN850");
                if (objflagFN850 != null) {
                    flagFN850 = Integer.parseInt(objflagFN850.toString());
                }
            } else if (action.toString().equals("reloadfordays1")) {
                Object objDaysss = getRequest().getParameter("dayID");
                if (objDaysss != null) {
                    idmobiSAVE = Integer.parseInt(objDaysss.toString());
                }
                Object objnd131 = getRequest().getParameter("startDTD");
                if (objnd131 != "") {
                    setDateStatus(Util.parseDate(objnd131.toString(), "dd/MM/yyyy"));
                }
                Object objnd1311 = getRequest().getParameter("endDTD");
                if (objnd1311 != "") {
                    setEndDateSta(Util.parseDate(objnd1311.toString(), "dd/MM/yyyy"));
                }

                System.out.println("---------------NGAY THANG LOAD---------------------------" + dateStatus + endDateSta);

            } else if (action.toString().equals("editEmp")) {
                if (SessionProvider.getSessionMapValue("PN100HD") != null) {
                    SessionProvider.removeSessionMapValue("pn100HD");
                }
                setIdmobiSAVE(1);
                System.out.println("-----------AAAAAAAAAAAAAAAAAAA-----" + idmobiSAVE);
                Object objflagFN850eee = getRequest().getParameter("ni104");
                if (objflagFN850eee != null) {
                    ni104 = Integer.parseInt(objflagFN850eee.toString());
                }
                Object stepObject = getRequest().getParameter("step");
                if (stepObject != null && stepObject.toString().equals("persion")) {
                    tip = 0;
                } else {
                    tip = 1;
                }
                this.pn100 = Integer.parseInt(ContextUtil.getRequestParameter("pn100"));
                this.sendPage = ContextUtil.getRequestParameter("table").toString();
                setEditpage("editajaxpage");
                listFindCustomer = getListCustomerById(pn100);
                flag = true;
                if (fk100 == 0) {
                    fk100 = Integer.parseInt(ContextUtil.getRequestParameter("ppk100"));
                }

                if (SessionProvider.getSessionMapValue("IDSAVEC") != null) {
                    SessionProvider.removeSessionMapValue("IDSAVEC");

                }
            } else if (action.toString().equals("delete")) {
                Object obj = ContextUtil.getRequestParameter("pn100");
                this.pn100 = Integer.parseInt(obj.toString());
            } else if (action.toString().equals("editDepart")) {
                Object obj = ContextUtil.getRequestParameter("pn100");
                this.pn100 = Integer.parseInt(obj.toString());
                listFindCustomer = getListCustomerById(pn100);
                show1 = true;
                show2 = false;
                flag = true;
            } else if (action.toString().equals("editDepartperson")) {
                Object obj = ContextUtil.getRequestParameter("pn100");
                this.pn100 = Integer.parseInt(obj.toString());
                show1 = false;
                show2 = true;
                flag = false;
            } else if (action.toString().equals("saveCustomerCOM")) {
                Object objFK100 = getRequest().getParameter("fk100");
                if (objFK100 != null) {
                    this.fk100 = Integer.parseInt(objFK100.toString());

                }
                Object objnv108 = getRequest().getParameter("nv108");
                if (objnv108 != null) {
                    this.nv108 = objnv108.toString();
                }

                Object objnv102 = getRequest().getParameter("nv102");
                if (objnv102 != null) {
                    this.nv102 = objnv102.toString();
                }
                Object objnv103 = getRequest().getParameter("nv103");
                if (objnv103 != null) {
                    this.nv103 = objnv103.toString();
                }
                Object objnv127 = getRequest().getParameter("nv127");
                if (objnv127 != null) {
                    this.nv127 = objnv127.toString();
                }
                Object objnv109 = getRequest().getParameter("nv109");
                if (objnv109 != null) {
                    this.nv109 = objnv109.toString();
                }
                try {
                    Object objfk300 = getRequest().getParameter("fk300");
                    if (objfk300 != null) {
                        this.FK300 = Util.parseInt(objfk300);
                    }
                    Object objfk330 = getRequest().getParameter("fk330");
                    if (objfk330 != null) {
                        this.FK330 = Util.parseInt(objfk330);
                    }

                } catch (Exception e) {
                }

                Object objfn600 = getRequest().getParameter("fn600");
                if (objfn600 != null) {
                    this.FN600 = Integer.parseInt(objfn600.toString());
                }
                Object nn117 = getRequest().getParameter("nn117");
                if (nn117 != null) {
                    this.nn117 = Integer.parseInt(nn117.toString());
                }
                Object objnd118 = getRequest().getParameter("nd118");
                if (objnd118 != null) {
                    try {

                        this.nd118 = Util.parseDate(objnd118.toString(), "dd/MM/yyyy");

                    } catch (Exception e) {
                    }
                }
                if (fk100 > 0) {
                    saveCustomer();
                }
                if (fk100 == 0) {
                    saveCustomer();
                }
            } else if (action.equals("sendSMS")) {
                Object objPhone = getRequest().getParameter("phone");
                if (objPhone != null) {
                    this.nv961 = objPhone.toString();

                }
                Object objHoten = getRequest().getParameter("hoten");
                if (objHoten != null) {
                    this.hoten = objHoten.toString();
                }
                Object objmv306 = getRequest().getParameter("mv306");
                if (objmv306 != null) {
                    this.mv306 = objmv306.toString();
                }
                Object objempString = getRequest().getParameter("redirect");
                if (objempString != null) {
                    this.empString = objempString.toString();
                }
            } else if (action.equals("reloadEmp1")) {
                System.out.println("----------------TUNG TTTTT");
                if (SessionProvider.getSessionMapValue("KEYKH") != null) {
                    SessionProvider.removeSessionMapValue("KEYKH");
                }
            }
                else if (action.equals("functionSearch")) {
                Object keyStr = getRequest().getParameter("keysearch");
                keySearch = keyStr.toString();

                Object typeint = getRequest().getParameter("typesearch");
                if (typeint != null) {
                    typeSearch = Integer.parseInt(typeint.toString());
                    if (typeSearch == 0) {
                        pagename = "ALL";
                    }
                }
                System.out.println("----------KEY SEARCH-------" + keySearch + "---TYPE---" + typeSearch + "--PAGE---" + pagename);
            }
            else if (action.equals("reloadGroup")) {
                Object objPK400 = getRequest().getParameter("pk400");
                groupID = Integer.parseInt(objPK400.toString());
            } else if (action.equals("reloadGroupCN")) {
                if (SessionProvider.getSessionMapValue("groupcustomerID") != null) {
                    SessionProvider.removeSessionMapValue("groupcustomerID");
                }
            } else if (action.equals("linkCus")) {
                typeSearch = 0;
                keySearch = "";
            } else if (action.equals("reloadfordays")) {
                objDayss = getRequest().getParameter("dayss");
                if (objDayss != null) {
                    dayss = Integer.parseInt(objDayss.toString());
                }


            } else if (action.equals("checkExistEmail")) {
                Object objEmail = getRequest().getParameter("email");
                if (objEmail != null) {
                    email = objEmail.toString();
                    checkEmailExist(email);
                }


            } else if (action.equals("checkExistMobi")) {
                Object objEmail = getRequest().getParameter("email");
                if (objEmail != null) {
                    mobi = objEmail.toString();
                    checkEmailExistMobi(mobi);
                }


            } else if (action.equals("checkExistcmnd")) {
                Object objEmail = getRequest().getParameter("cmnd");
                if (objEmail != null) {
                    mobi = objEmail.toString();
                    checkEmailExistCMND(mobi);
                }


            } else if (action.equals("addCusp100")) {
                Object f = getRequest().getParameter("p100");
                Object s = getRequest().getParameter("valueC");


                if ("false".equals(s.toString())) {
                    for (int i = 0; i < listSelected.size(); i++) {
                        if (listSelected.get(i).pn100 == Integer.parseInt(f.toString())) {
                            listSelected.remove(i);
                            break;
                        }
                    }
                } else {
                    for (int i = 0; i < listN100.size(); i++) {
                        if (listN100.get(i).pn100 == Integer.parseInt(f.toString())) {
//                            if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                            listSelected.add(listN100.get(i));
                            break;
//                            }
                        }
                    }
                }
                List<N100> listgetrros = (List<N100>) listSelected;

                System.out.println("----------BAONHIEU ROW-------" + listgetrros.size());
                SessionProvider.setSessionMapValue("NUMBERPER", listgetrros.size());
                SessionProvider.setSessionMapValue("listSelectedEx", listSelected);
                SessionProvider.setSessionMapValue("listN100", listN100);

                //check All
            } else if (action.equals("addAllCusp100")) {
                Object va = getRequest().getParameter("boool");
                if ("true".equals(va.toString())) {
                    listSelected.clear();
                    for (int i = 0; i < listN100.size(); i++) {
//                        if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                        listSelected.add(listN100.get(i));
//                        }
                    }
                } else {
                    listSelected.clear();
                }
                List<N100> listgetrros = (List<N100>) listSelected;
                System.out.println("----------BAONHIEU ROW-------" + listgetrros.size());
                SessionProvider.setSessionMapValue("NUMBERPER", listgetrros.size());
                SessionProvider.setSessionMapValue("listSelectedEx", listSelected);
                SessionProvider.setSessionMapValue("listN100", listN100);
            } else if (action.equals("editCRM")) {
                if (SessionProvider.getSessionMapValue("PN100HD") != null) {
                    SessionProvider.removeSessionMapValue("pn100HD");
                }
                if (SessionProvider.getSessionMapValue("IDSAVEC") != null) {
                    SessionProvider.removeSessionMapValue("IDSAVEC");
                }
                try {
                    Object objFV050 = getRequest().getParameter("FV050EE");
                    if (objFV050 != null) {
                        this.FV050EE = Integer.parseInt(objFV050.toString());
                    }
                    System.out.println("---------editCRM----------------" + FV050EE);
                } catch (Exception e) {
                }

                try {
                    Object objFV050DD = getRequest().getParameter("personalDD");
                    if (objFV050DD != null) {
                        this.fn850 = Integer.parseInt(objFV050DD.toString());
                    }
                    System.out.println("---------ID NGUOI DAIDIEN ----------------" + FV050EE);
                } catch (Exception e) {
                }

                try {
                    Object FV050EEDD = getRequest().getParameter("FV050EEDD");
                    if (FV050EEDD != null) {
                        this.current = Integer.parseInt(FV050EEDD.toString());
                    }
                    System.out.println("---------ID NGUOI DAIDIEN ----------------" + FV050EE);
                } catch (Exception e) {
                }
                Object objMobiid = getRequest().getParameter("idmobi");
                if (objMobiid != null) {
                    this.idmobiSAVE = Integer.parseInt(objMobiid.toString());
                }
                Object objfn100i = getRequest().getParameter("fn100i");
                if (objfn100i != null) {
                    this.pn100 = Integer.parseInt(objfn100i.toString());

                } else {
                    Object objfn100 = getRequest().getParameter("fn100");
                    if (objfn100 != null) {
                        this.pn100 = Integer.parseInt(objfn100.toString());

                    }
                }
                Object objnv115 = getRequest().getParameter("nv115");
                if (objnv115 != null) {
                    this.nv108 = objnv115.toString();
                }
                Object objnv102 = getRequest().getParameter("nv102");
                if (objnv102 != null) {
                    this.nv102 = objnv102.toString();
                }
                Object objnv103 = getRequest().getParameter("nv103");
                if (objnv103 != null) {
                    this.nv103 = objnv103.toString();
                }
                Object objnv123 = getRequest().getParameter("nv123");
                if (objnv123 != null) {
                    this.nv123 = objnv123.toString();
                }
                Object objnv127 = getRequest().getParameter("nv127");
                if (objnv127 != null) {
                    this.nv127 = objnv127.toString();
                }
                Object objmobi = getRequest().getParameter("mobi");
                if (objmobi != null) {
                    this.mobi = objmobi.toString();
                }
                Object objfk100 = getRequest().getParameter("fk100");
                if (objfk100 != null) {
                    this.fk100 = Integer.parseInt(objfk100.toString());
                }
                Object objtel = getRequest().getParameter("tel");
                if (objtel != null) {
                    this.tel = objtel.toString();
                }
                Object objemail = getRequest().getParameter("email");
                if (objemail != null) {
                    this.email = objemail.toString();
                }
                Object objnd118 = getRequest().getParameter("nd118");
                if (objnd118 != "") {
                    setNd118(Util.parseDate(objnd118.toString(), "dd/MM/yyyy"));
                }

                Object objnd131 = getRequest().getParameter("nd131");
                if (objnd131 != "") {
                    setDateStatus(Util.parseDate(objnd131.toString(), "dd/MM/yyyy"));
                }
                Object objnv130 = getRequest().getParameter("nv130");
                if (objnv130 != null) {
                    this.nv130 = objnv130.toString();
                }
                Object objfk330 = getRequest().getParameter("fk330");
                if (objfk330 != null) {
                    this.FK330 = Integer.parseInt(objfk330.toString());
                }
                Object objfk300 = getRequest().getParameter("fk300");
                if (objfk300 != null) {
                    this.FK300 = Integer.parseInt(objfk300.toString());
                }
                Object nn117 = getRequest().getParameter("nn117");
                if (nn117 != null) {
                    this.nn117 = Integer.parseInt(nn117.toString());
                }
                Object objfn600 = getRequest().getParameter("fn600");
                if (objfn600 != null) {
                    this.FN600 = Integer.parseInt(objfn600.toString());
                    if (FN600 != 3) {
                        FN600 = 2;
                    }

                }
                System.out.println("---------nn117 gettr----------" + nn117);

                saveCustomer();


            }



        }

        Object pnFN600 = getRequest().getParameter("fn600");
        if (pnFN600 != null) {
            FN600 = Integer.parseInt(pnFN600.toString());// nhan vien khach hang =3 , nguoi dai dien = 4
            if (pn100 == 0) {
                ni104 = 0;
                SessionProvider.setSessionMapValue("customertype", ni104);
            }
            if (FN600 == 4) { // nguoi dai dien
                FN600 = 3;
                nn117 = 1;
            }

        }
        Object pnfk100 = getRequest().getParameter("id");
        if (pnfk100 != null) {
            fk100 = Integer.parseInt(pnfk100.toString());
        }
        Object objNN117 = getRequest().getParameter("nn117");
        if (objNN117 != null) {
            this.nn117 = Integer.parseInt(objNN117.toString());
        }
        selectItemN900 = comboboxUtil.getSelectedN900Comb(this.fn850gt);



        //paging
        int a;
        System.out.println("D:-- listEmployee is not null ");
        Object ppage = getRequest().getParameter("p");
        if (ppage != null) {
            try {
                a = Integer.parseInt(ppage.toString());
            } catch (Exception ex) {
                a = 1;
            }
            if (a == 1) {
                setCurrent(1);
                setOffset(0);
                System.out.println("D:-- setOffset: " + 0);
            } else {
                setCurrent(a);
                setOffset((a - 1) * Limit);
                System.out.println("D:-- setOffset: " + ((a - 1) * Limit));
            }
            System.out.println("D:-- page: " + a);

        } else {
            SessionProvider.setSessionMapValue("typeSearch", null);
            SessionProvider.setSessionMapValue("keySearch", null);
            setCurrent(1);
            setOffset(0);
            System.out.println("D:-- page: 1");
        }

    }

    public void checkEmailExist(String email1) {
        try {
            EmployeeStore store = new EmployeeStore();
            int count = store.checkMailExist(email1, getLogin().getUserName());
            if (count != 0) {
                beginContructor = 1;
            } else {
                beginContructor = 0;

            }
        } catch (Exception e) {
        }
    }

    public int checkEmailExistMobiInt(String mobi) {
        try {
            EmployeeStore store = new EmployeeStore();
            int count = store.checkMobiExist(mobi, getLogin().getUserName());
            if (count != 0) {
                beginContructor = 1;
            } else {
                beginContructor = 0;

            }
            return count;
        } catch (Exception e) {
            return 0;
        }
    }
    // kiem tra mobi

    public void checkEmailExistMobi(String mobi) {
        try {
            EmployeeStore store = new EmployeeStore();
            int count = store.checkMobiExist(mobi, getLogin().getUserName());
            if (count != 0) {
                beginContructor = 1;
            } else {
                beginContructor = 0;

            }
        } catch (Exception e) {
        }
    }

    public void checkEmailExistCMND(String cmnd) {
        try {
            EmployeeStore store = new EmployeeStore();
            int count = store.checkMobiCMND(cmnd, getLogin().getUserName());
            if (count != 0) {
                beginContructor = 1;
            } else {
                beginContructor = 0;

            }
        } catch (Exception e) {
        }
    }

    // Search nhân viên trong form công ty TÙNG
    public void reloadform(ActionEvent event) {
        System.out.println("---------------------AADD-------" + keysearchKH + typesearchKH);
        SessionProvider.setSessionMapValue("KEYKH", keysearchKH);// tim kiếm lahcsh hang cho cong ty
    }

    public List getSelectItems() {
        List selectItems = new ArrayList();
        selectItems.add(new SelectItem("Mr", "Mr."));
        selectItems.add(new SelectItem("Ms", "Ms."));
        //selectItems.add(new SelectItem("Dr", "Dr."));
        // selectItems.add(new SelectItem("Pro", "Prof."));
        return selectItems;

    }

    public String formatNumber(int num) {
        String snum = Util.numberformater(num);
        return snum;
    }

    public void saveCustomer() {
        String birthday1 = "";
        try {
            if (this.nv113 == null || this.nv113.isEmpty()) {
                this.nv113 = getLogin().getUserName();
            }
            String table = "N100";
            if (FN600 == 3) {
                table = "K100";

            }
            SessionProvider.setSessionMapValue("customertype", ni104);

            int roweffect = 0;
            if (nv108 != null) {
                if (nv108.equals("Mr")) {
                    nv107 = "M";
                } else if (nv108.equals("Ms")) {
                    nv107 = "F";
                }//....sau nay ntn them vao
            }
            if (SessionProvider.getSessionMapValue("NI104UP") != null) {
                ni104 = Util.parseInt(SessionProvider.getSessionMapValue("NI104UP"));
            } else {
                ni104 = 0;
            }
            if (fk100 == 0) {
                fk100 = getLogin().getFk100();
            }
            int countmobi = 0;

            if (idmobiSAVE != 0) {
                String namemobi = null;
                if (SessionProvider.getSessionMapValue("MOBIBIBI") != null) {
                    namemobi = SessionProvider.getSessionMapValue("MOBIBIBI").toString();
                }
                System.out.println(mobi + "00------MOBIIIIIIIIIIIIIIIIIIIIIIIIIIII-------" + namemobi);
                if (mobi.equals(namemobi)) {
                } else {

                    if (mobi.length() > 0) {
                        countmobi = checkEmailExistMobiInt(mobi);
                    }
                }
            } else {
                System.out.println(pn100 + "," + SessionProvider.getSessionMapValue("IDSAVEC") + "-------------MOBI-------" + mobi);
                if (mobi == null || mobi.equals("")) {
                } else {
                    countmobi = checkEmailExistMobiInt(mobi);
                }
            }
            if (countmobi != 0) {
                setMessage("TRÙNG MOBI, CẬP NHẬT KHÔNG THÀNH CÔNG!");
                setBeginContructor(0);
            } else {
                if (!this.nv102.equals("")) {
                    if (SessionProvider.getSessionMapValue("IDSAVEC") != null) {
                        roweffect = customerStore.updateN100By(Util.parseInt(SessionProvider.getSessionMapValue("IDSAVEC")), getFN600(), fk100, getLogin().getCompanyNo(), this.nv102, this.nv103, this.ni104, this.ni105,
                                null, this.nv107, this.nv108, this.nv109, this.nv110, this.nv111, this.getNv112(),
                                this.nv113, 1, "K100", null, nn117, Util.toSQLDate(this.nd118), Util.UnUnicode(nv102), Util.UnUnicode(nv103), nv123, null, null, null, nv127, Util.UnUnicode(this.getNv127()), this.getNv130(), Util.toSQLDate(this.dateStatus), getLogin().getModule(), this.fn550, this.FK300, this.FK330, getLogin().getUserName());
                    } else {
                        roweffect = customerStore.updateN100By(pn100, getFN600(), fk100, getLogin().getCompanyNo(), this.nv102, this.nv103, this.ni104, this.ni105,
                                null, this.nv107, this.nv108, this.nv109, this.nv110, this.nv111, this.getNv112(),
                                this.nv113, 1, "K100", null, nn117, Util.toSQLDate(this.nd118), Util.UnUnicode(nv102), Util.UnUnicode(nv103), nv123, null, null, null, nv127, Util.UnUnicode(this.getNv127()), this.getNv130(), Util.toSQLDate(this.dateStatus), getLogin().getModule(), this.fn550, this.FK300, this.FK330, getLogin().getUserName());

                        if (roweffect != 0) {
                            SessionProvider.setSessionMapValue("IDSAVEC", roweffect);
                            System.out.println("------ SESSION----" + SessionProvider.getSessionMapValue("IDSAVEC"));
                        }
                    }
                } else {
                    setMessage(getResourceString("error"));
                }
                if (roweffect > 0) {
                    pn100 = roweffect;
                    if (pn100 > 0) {
                        beginContructor = pn100;
                        setMessage(getResourceString("success"));
                        int count = 0;
                        ContactStore contactStore = new ContactStore();
                        count = contactStore.updateN950By(pn100, 1, "N100", null,
                                null, null, null, null, null, 1, this.tel, null, this.notice, this.mobi,
                                null, null, null, null, null, this.email, null, null, null, null, 1, null, null, null, getLogin().getUserName());
//                    this.NV961 = this.mobi;
//                    this.NV967 = this.email;
//                    this.NV958 = this.tel;

                    } else {
                        setMessage(getResourceString("error"));
                        beginContructor = 0;
                    }

                    setMessage(getResourceString("success"));
                } else {
                    setMessage(getResourceString("error"));
                    beginContructor = 0;
                }

                if (roweffect > 0 && FV050EE > 0) {
                    V030Store store = new V030Store();
                    int coutn = store.updateV030(FV050EE, pn100, null, null, 0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0, getLogin().getUserName());

                } else if (roweffect > 0 && current > 0 && fn850 > 0) {
                    CustomerStore store = new CustomerStore();
                    int count = store.update2ColumnTAB(null, "V030", "FN100C", String.valueOf(pn100), "FV050", current, "FN100", fn850, getLogin().getUserName());
                    System.out.println("----------aa id ==========AAAAAAAAA=========================" + count);
                }

                if (pagereload != null) {
                    if (sendPage == null || sendPage.equals("")) {
                        if (FN600 == 3 && pagereload.equals("cuscompany.jsp")) {
                            sendRedirectURL(pagereload, fk100, 2 + nn117);
                            showGlobalReport(true, getResourceString("datasavesuccessful"));

                        } else if (pagereload.equals("supplier.jsp")) {
                            sendRedirectURL(pagereload, fk100, 2);
                            showGlobalReport(true, getResourceString("datasavesuccessful"));

                        } else {
                            sendRedirect("customer.jsp" + "?type=" + this.ni104 + "&linkv300=" + Util.convertMD5(getRequest().getRequestURI()));
                        }
                    }
                }
            }


        } catch (Exception ex) {
            System.out.println("---errrrrrrrrrrrrrr---" + ex.getMessage());
            logger.debug("Check Information Employee" + ex.getMessage());
            setMessage("CẬP NHẬT KHÔNG THÀNH CÔNG !");

        }
    }

    public void search(ActionEvent ac) {
        SessionProvider.setSessionMapValue("search4customer", charSearch);
    }

    public void changeGroup(ActionEvent ac) {
        SessionProvider.setSessionMapValue("groupcustomerID", groupID);
        System.out.println("---change groupppppppppppppppppppppppppppppppppppppppppppppppppppppppppp" + groupID);

        // sendRedirect("customer.jsp");
    }

    public void deleteCustomer() {
        int roweffect = 0;
        if (pn100 > 0) {
            roweffect = customerInf.deleteEmployee(pn100, getLogin().getUserName());
            sendRedirect("customer.jsp");
            showGlobalReport(true, getResourceString("datasavesuccessful"));
        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
    }

    public List<N100> getListCustomerById(int pn100U) {
        List<N100> listById = null;

        try {
            if (ni104 == 1 || ni104 == 0) {
                SessionProvider.setSessionMapValue("NI104UP", ni104);
                System.out.println("------ khi no------" + SessionProvider.getSessionMapValue("NI104UP"));
            }
            System.out.println("===================================" + getLogin().getModule() + "," + getLogin().getCompanyNo() + "," + 0 + "," + 0 + "," + pn100U + "," + null + "," + ni104 + "," + 0 + "," + 20 + "," + 0 + "," + 1 + "," + getLogin().getUserName());
            listById = customerStore.getListCustomer(getLogin().getModule(), getLogin().getCompanyNo(), 0, 0, pn100U, null, ni104, 0, 20, 0, 1, getLogin().getUserName());
            Iterator ic = listById.iterator();
            while (ic.hasNext()) {
                N100 n100 = (N100) ic.next();

                this.pn100 = n100.pn100;
                this.fn600 = n100.fn600;// Phan biet khach hang voi nhan vien
                this.fk100 = n100.fk100;//
                this.fh200 = n100.fh200;// thuoc cong ty
                this.nv102 = n100.nv102;//Ho
                this.nv103 = n100.nv103;//Ten
                this.nv107 = n100.nv107;//gioi tinh
                this.nv108 = n100.nv108;//tieu de
                this.nv109 = n100.nv109;//Tinh trang gia dinh
                this.email = n100.getNv967();// email
                this.mobi = n100.getNv958();// mobi
                SessionProvider.setSessionMapValue("MOBIBIBI", mobi);
                this.nv110 = n100.nv110;//
                this.ni105 = n100.ni105;
                this.ni104 = n100.ni104;
                // System.out.println("------ khi n--"+ni104);

                this.nv111 = n100.nv111;//chuc vu
                this.nd118 = n100.nd118;//ngay sinh
                this.dateStatus = n100.getNd131();

                this.nv962 = n100.getNv962();//email
                this.fn850gt = n100.getFn850gt();
                this.nn117 = n100.getNn117();

                this.fn550 = n100.getFn550();
                this.fn850 = n100.getFn850();
                this.nv127 = n100.getNv127();

                this.nv112 = n100.nv112;
                this.nv113 = n100.nv113;
                this.nv130 = n100.getNv130();
                this.notice = n100.getNv130();
                this.FK300 = n100.getPk300();
                this.FK330 = n100.getPk330();
                System.out.println("---ghi chu-------- -" + nv130);
            }
            return listById;
        } catch (Exception ex) {
            logger.debug("*************" + ex.getMessage());
            return null;
        }

    }

    public List<SelectItem> getListSelectItems() {
        List<N100> listN100Select = customerStore.getSelectItemN550(getLogin().getModule(), 99, 1, getLogin().getUserName());
        Iterator ic = listN100Select.iterator();
        List<SelectItem> listSelected = new ArrayList<SelectItem>();
        while (ic.hasNext()) {
            N100 n100 = (N100) ic.next();
            SelectItem item = new SelectItem(n100.getVal(), n100.getLabel());

            listSelected.add(item);
        }
        return listSelected;
    }

    public List<SelectItem> getSelectedN550Comb() {

        N550Store store = new N550Store();
        List<SelectItem> listItemed = new ArrayList<SelectItem>();
        try {
            List<N550> listItemN900 = store.findAllN550ForCombo(getLogin().getModule(), 99, 1, getLogin().getUserName());
            Iterator ic = listItemN900.iterator();

            while (ic.hasNext()) {
                N550 n550 = (N550) ic.next();
                SelectItem item = new SelectItem(n550.getPn550(), n550.getNv552());
                listItemed.add(item);
            }
        } catch (Exception e) {
        }

        return listItemed;

    }

    public void changeCombN850forN900(ValueChangeEvent event) {
        this.fn850 = Integer.parseInt(event.getNewValue().toString());
        System.out.println("-------CCC--" + fn850);
        selectItemN900 = comboboxUtil.getSelectedN900Comb(Integer.parseInt(event.getNewValue().toString()));
        System.out.println("-------------ALOLAOLAO====" + selectItemN900.size());
    }

    /**
     * @return the selectCombN850
     */
    public List<SelectItem> getSelectCombN850() {
        selectCombN850 = comboboxUtil.getSelectedN850Comb();
        return selectCombN850;
    }

    public List<Q400> getListGroupQ400() throws SQLException, InstantiationException {
        try {
            K400Store k400Store = new K400Store();
            if (getListQ400() == null) {
                setListQ400(k400Store.CombK400(getLogin().getModule(), getLogin().getCompanyNo(), 0, getLogin().getUserName()));
            }

            return listQ400;
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

    public void updateK400() throws SQLException, InstantiationException {
        Object objPn100 = getRequest().getParameter("pn100");
        Object objPk400 = getRequest().getParameter("pk400");

        if (objPk400 != null && objPn100 != null) {
            try {
                K400Store store = new K400Store();
                store.updateK450(Integer.parseInt(objPk400.toString()), Integer.parseInt(objPn100.toString()), "N100C", null, getLogin().getUserName());
                sendRedirect("customer.jsp");
                showGlobalReport(true, getResourceString("datasavesuccessful"));

            } catch (IllegalAccessException ex) {

                java.util.logging.Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex);
                sendRedirect("customer.jsp");
                showGlobalReport(true, getResourceString("datasuccessfail"));
            }
        }

    }

    // Lít nhân vien
    public List<N100> getListdifn100() {
        try {
            CustomerStore store = new CustomerStore();
            if (SessionProvider.getSessionMapValue("KEYKH") != null) {
                keysearchKH = SessionProvider.getSessionMapValue("KEYKH").toString();
                listdifn100 = store.getListCustomer_NA(getLogin().getModule(), getLogin().getCompanyNo(), keysearchKH, Offset, 1000, 0, 0, getLogin().getUserName());
                System.out.println("----list222222---------- " + listdifn100.size());
            } else {
                listdifn100 = store.getListN100DifK100(getLogin().getModule(), getLogin().getCompanyNo(), 0, 0, 1, 30, getLogin().getUserName());
                System.out.println("----list " + listdifn100.size());
            }

            return listdifn100;
        } catch (Exception e) {
            System.out.println("D:- Error from getListdifn100 (lay danh sach nhan vien): " + e.getMessage());
            return new ArrayList<N100>();
        }

    }

    // Lít nhân vien của công ty
    public List<N100> getListdifn100C() {
        try {
            System.out.println("--------------" + getLogin().getModule() + "," + getLogin().getCompanyNo() + "," + 0 + "," + fk100 + "," + 1 + "," + getLogin().getUserName());
            if (SessionProvider.getSessionMapValue("PN100HD") != null) {
                fk100 = Util.parseInt(SessionProvider.getSessionMapValue("PN100HD"));
            }
            listemp = customerInf.getListCustomerCompany(getLogin().getModule(), getLogin().getCompanyNo(), 0, fk100, 1, getLogin().getUserName());

            return listemp;
        } catch (Exception ex) {
            return null;
        }

    }

    public List<Q400> getListQ400Filter() throws SQLException, InstantiationException {
        K400Store k400Store = new K400Store();
        listQ400S = (List<Q400>) SessionProvider.getSessionMapValue("listQ400S");
        if (listQ400S == null) {
            try {
                listQ400S = k400Store.COMBTABK400F(getLogin().getModule(), getLogin().getCompanyNo(), getLogin().getId(), 0, "N100C", getLogin().getUserName());

            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex);
                return null;

            }
        }
        SessionProvider.setSessionMapValue("listQ400S", listQ400S);
        return listQ400S;
    }

    //List Tour
    public List<V500> getListV500() {
        listV500 = (List<V500>) SessionProvider.getSessionMapValue("listV500");
        if (listV500 == null) {
            V500Store v500Store = new V500Store();
            listV500 = v500Store.getListCombV050SGT(getLogin().getModule(), getLogin().getCompanyNo(), null, "T", getLogin().getUserName());

            SessionProvider.setSessionMapValue("listV500", listV500);
        }
        return listV500;
    }

//update note
    public void updateNote() {
        CustomerStore customerStore = new CustomerStore();
        System.out.println("-----nv130---" + pn100 + "------------" + nv130);
        if (this.getPn100() > 0) {
            customerStore.updateColumnN100(null, "N100", "NV130", this.getNv130(), "PN100", this.getPn100(), getLogin().getUserName());
            showGlobalReport(true, getResourceString("success"));
            sendRedirect("customer.jsp?linkhref=" + getKapiMenu().getMd5url());
        } else {
            showGlobalReport(true, getResourceString("error"));
            sendRedirect("customer.jsp?linkhref=" + getKapiMenu().getMd5url());
        }

    }

    /**
     * @return the pn100
     */
    public int getPn100() {
        return pn100;
    }

    /**
     * @param pn100 the pn100 to set
     */
    public void setPn100(int pn100) {
        this.pn100 = pn100;
    }

    /**
     * @return the fn600
     */
    public int getFn600() {
        return fn600;
    }

    /**
     * @param fn600 the fn600 to set
     */
    public void setFn600(int fn600) {
        this.fn600 = fn600;
    }

    /**
     * @return the fk100
     */
    public int getFk100() {
//         if(SessionProvider.getSessionMapValue("PN100HD")!=null){
//                fk100 = Util.parseInt(SessionProvider.getSessionMapValue("PN100HD"));
//            }
        return fk100;
    }

    /**
     * @param fk100 the fk100 to set
     */
    public void setFk100(int fk100) {
        this.fk100 = fk100;
    }

    /**
     * @return the fh200
     */
    public int getFh200() {
        return fh200;
    }

    /**
     * @param fh200 the fh200 to set
     */
    public void setFh200(int fh200) {
        this.fh200 = fh200;
    }

    /**
     * @return the nv102
     */
    public String getNv102() {
        return nv102;
    }

    /**
     * @param nv102 the nv102 to set
     */
    public void setNv102(String nv102) {
        this.nv102 = nv102;
    }

    /**
     * @return the nv103
     */
    public String getNv103() {
        return nv103;
    }

    /**
     * @param nv103 the nv103 to set
     */
    public void setNv103(String nv103) {
        this.nv103 = nv103;
    }

    /**
     * @return the nv107
     */
    public String getNv107() {
        return nv107;
    }

    /**
     * @param nv107 the nv107 to set
     */
    public void setNv107(String nv107) {
        this.nv107 = nv107;
    }

    /**
     * @return the nv108
     */
    public String getNv108() {
        return nv108;
    }

    /**
     * @param nv108 the nv108 to set
     */
    public void setNv108(String nv108) {
        this.nv108 = nv108;
    }

    /**
     * @return the nv109
     */
    public String getNv109() {
        return nv109;
    }

    /**
     * @param nv109 the nv109 to set
     */
    public void setNv109(String nv109) {
        this.nv109 = nv109;
    }

    /**
     * @return the nd118
     */
    public Date getNd118() {
        return nd118;
    }

    /**
     * @param nd118 the nd118 to set
     */
    public void setNd118(Date nd118) {
        this.nd118 = nd118;
    }

    /**
     * @return the customerInf
     */
    public CustomerInf getCustomerInf() {
        return customerInf;
    }

    /**
     * @param customerInf the customerInf to set
     */
    public void setCustomerInf(CustomerInf customerInf) {
        this.customerInf = customerInf;
    }

    /**
     * @return the charSearch
     */
    public String getCharSearch() {
        if (SessionProvider.getSessionMapValue("search4customer") != null) {
            charSearch = SessionProvider.getSessionMapValue("search4customer").toString();
        }
        return charSearch;
    }

    /**
     * @param charSearch the charSearch to set
     */
    public void setCharSearch(String charSearch) {
        this.charSearch = charSearch;
    }

    /**
     * @return the flag
     */
    public boolean isFlag() {
        return flag;
    }

    /**
     * @param flag the flag to set
     */
    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    /**
     * @return the listFindCustomer
     */
    public List<N100> getListFindCustomer() {
        return listFindCustomer;
    }

    /**
     * @param listFindCustomer the listFindCustomer to set
     */
    public void setListFindCustomer(List<N100> listFindCustomer) {
        this.listFindCustomer = listFindCustomer;
    }

    /**
     * @return the idSearch
     */
    public String getIdSearch() {
        return idSearch;
    }

    /**
     * @param idSearch the idSearch to set
     */
    public void setIdSearch(String idSearch) {
        this.idSearch = idSearch;
    }

    /**
     * @return the date_nd118
     */
    public String getDate_nd118() {
        return date_nd118;
    }

    /**
     * @param date_nd118 the date_nd118 to set
     */
    public void setDate_nd118(String date_nd118) {
        this.date_nd118 = date_nd118;
    }

    /**
     * @return the listN100
     */
    public List<N100> getListN100() {
        return listN100;
    }

    /**
     * @param listN100 the listN100 to set
     */
    public void setListN100(List<N100> listN100) {
        this.listN100 = listN100;
    }

    /**
     * @return the nv110
     */
    public String getNv110() {
        return nv110;
    }

    /**
     * @param nv110 the nv110 to set
     */
    public void setNv110(String nv110) {
        this.nv110 = nv110;
    }

    /**
     * @return the nv111
     */
    public String getNv111() {
        return nv111;
    }

    /**
     * @param nv111 the nv111 to set
     */
    public void setNv111(String nv111) {
        this.nv111 = nv111;
    }

    /**
     * @return the fn550
     */
    public int getFn550() {

        return fn550;
    }

    /**
     * @param fn550 the fn550 to set
     */
    public void setFn550(int fn550) {
        this.fn550 = fn550;
    }

    /**
     * @return the selectItemsN550
     */
    public List<SelectItem> getSelectItemsN550() {
        return selectItemsN550;
    }

    /**
     * @param selectItemsN550 the selectItemsN550 to set
     */
    public void setSelectItemsN550(List<SelectItem> selectItemsN550) {
        this.selectItemsN550 = selectItemsN550;
    }

    /**
     * @return the nv113
     */
    public String getNv113() {
        return nv113;
    }

    /**
     * @param nv113 the nv113 to set
     */
    public void setNv113(String nv113) {
        this.nv113 = nv113;
    }

    /**
     * @return the n900Inf
     */
    public N900Inf getN900Inf() {
        return n900Inf;
    }

    /**
     * @param n900Inf the n900Inf to set
     */
    public void setN900Inf(N900Inf n900Inf) {
        this.n900Inf = n900Inf;
    }

    /**
     * @return the selectItemN900
     */
    public List<SelectItem> getSelectItemN900() {

        return selectItemN900;
    }

    /**
     * @param selectItemN900 the selectItemN900 to set
     */
    public void setSelectItemN900(List<SelectItem> selectItemN900) {
        this.selectItemN900 = selectItemN900;
    }

    /**
     * @return the listemp
     */
    public List<N100> getListemp() {
        return listemp;
    }

    /**
     * @param listemp the listemp to set
     */
    public void setListemp(List<N100> listemp) {
        this.listemp = listemp;
    }

    /**
     * @return the nv967
     */
    public String getNv967() {
        return nv967;
    }

    /**
     * @param nv967 the nv967 to set
     */
    public void setNv967(String nv967) {
        this.nv967 = nv967;
    }

    /**
     * @return the nv958
     */
    public String getNv958() {
        return nv958;
    }

    /**
     * @param nv958 the nv958 to set
     */
    public void setNv958(String nv958) {
        this.nv958 = nv958;
    }

    /**
     * @return the nv962
     */
    public String getNv962() {
        return nv962;
    }

    /**
     * @param nv962 the nv962 to set
     */
    public void setNv962(String nv962) {
        this.nv962 = nv962;
    }

    /**
     * @return the old
     */
    public String getOld() {
        return old;
    }

    /**
     * @param old the old to set
     */
    public void setOld(String old) {
        this.old = old;
    }

    /**
     * @return the nv119
     */
    public String getNv119() {
        return nv119;
    }

    /**
     * @param nv119 the nv119 to set
     */
    public void setNv119(String nv119) {
        this.nv119 = nv119;
    }

    /**
     * @return the ni104
     */
    public int getNi104() {

        if (SessionProvider.getSessionMapValue("customertype") != null) {
            ni104 = Integer.parseInt(SessionProvider.getSessionMapValue("customertype").toString());
        }
        return ni104;
    }

    /**
     * @param ni104 the ni104 to set
     */
    public void setNi104(int ni104) {
        this.ni104 = ni104;
    }

    /**
     * @return the show1
     */
    public boolean isShow1() {
        return show1;
    }

    /**
     * @param show1 the show1 to set
     */
    public void setShow1(boolean show1) {
        this.show1 = show1;
    }

    /**
     * @return the show2
     */
    public boolean isShow2() {
        return show2;
    }

    /**
     * @param show2 the show2 to set
     */
    public void setShow2(boolean show2) {
        this.show2 = show2;
    }

    /**
     * @return the sendPage
     */
    public String getSendPage() {
        return sendPage;
    }

    /**
     * @param sendPage the sendPage to set
     */
    public void setSendPage(String sendPage) {
        this.sendPage = sendPage;
    }

    /**
     * @return the nv112
     */
    public String getNv112() {
        if (nv112 == null || nv112.isEmpty()) {
            nv112 = getLogin().getUserName();
        }
        return nv112;
    }

    /**
     * @param nv112 the nv112 to set
     */
    public void setNv112(String nv112) {
        this.nv112 = nv112;
    }

    /**
     * @return the fn850
     */
    public int getFn850() {
        return fn850;
    }

    /**
     * @param fn850 the fn850 to set
     */
    public void setFn850(int fn850) {
        this.fn850 = fn850;
    }

    /**
     * @param selectCombN850 the selectCombN850 to set
     */
    public void setSelectCombN850(List<SelectItem> selectCombN850) {
        this.selectCombN850 = selectCombN850;
    }

    /**
     * @return the FN600
     */
    public int getFN600() {
        return FN600;
    }

    /**
     * @param FN600 the FN600 to set
     */
    public void setFN600(int FN600) {
        this.FN600 = FN600;
    }

    /**
     * @return the fn850gt
     */
    public int getFn850gt() {
        return fn850gt;
    }

    /**
     * @param fn850gt the fn850gt to set
     */
    public void setFn850gt(int fn850gt) {
        this.fn850gt = fn850gt;
    }

    /**
     * @return the ni105
     */
    public int getNi105() {
        return ni105;
    }

    /**
     * @param ni105 the ni105 to set
     */
    public void setNi105(int ni105) {
        this.ni105 = ni105;
    }

    /**
     * @return the beginContructor
     */
    public int getBeginContructor() {
        return beginContructor;
    }

    /**
     * @param beginContructor the beginContructor to set
     */
    public void setBeginContructor(int beginContructor) {
        this.beginContructor = beginContructor;
    }

    /**
     * @return the listpersion
     */
    public List<N100> getListpersion() {
        if (SessionProvider.getSessionMapValue("PN100HD") != null) {
            fk100 = Util.parseInt(SessionProvider.getSessionMapValue("PN100HD"));
        }
        listpersion = customerInf.getListCustomerCompany(getLogin().getModule(), 99, 0, fk100, 0, getLogin().getUserName());
        return listpersion;
    }

    /**
     * @param listpersion the listpersion to set
     */
    public void setListpersion(List<N100> listpersion) {
        this.listpersion = listpersion;
    }

    /**
     * @return the nn117
     */
    public int getNn117() {
        return nn117;
    }

    /**
     * @param nn117 the nn117 to set
     */
    public void setNn117(int nn117) {
        this.nn117 = nn117;
    }

    /**
     * @return the pagereload
     */
    public String getPagereload() {
        return pagereload;
    }

    /**
     * @param pagereload the pagereload to set
     */
    public void setPagereload(String pagereload) {
        this.pagereload = pagereload;
    }

    public List<N100> getListCustomer() {
        int flags = 0;
        int flag1 = 0;
        int flag2 = 0;
        try {
            if (SessionProvider.getSessionMapValue("submitSearch") != null && SessionProvider.getSessionMapValue("submitSearch").toString().equals("true")) {
                setTypeSearch(0);

            }

            Object o = SessionProvider.getSessionMapValue("typeSearch");
            if (o != null) {
                int type;
                try {
                    type = Integer.parseInt(o.toString());
                } catch (Exception e) {
                    type = 0;
                }
                setTypeSearch(type);

            }

            Object o2 = SessionProvider.getSessionMapValue("keySearch");
            if (o2 != null) {

                setKeySearch(o2.toString());

            }

            if (getKeySearch() != null && getKeySearch().contains("Nhập từ khóa")) {
                setKeySearch(getLogin().getCharacter());
            }

            N100 n100;
            if (getTypeSearch() == 1) {
                flags = 1;
                listN100 = customerInf.getListCustomer_COMPANY(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

            } else if (getTypeSearch() == 2) {
                flags = 2;
                listN100 = customerInf.getListCustomer_MO(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

            } else if (getTypeSearch() == 3) {
                flags = 3;
                listN100 = customerInf.getListCustomer_NA(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

            } else if (getTypeSearch() == 4) {
                flags = 4;
                System.out.println("============TUNG TUNG-----" + getLogin().getModule() + "," + getLogin().getCompanyNo() + "," + 0 + "," + 0 + "," + keySearch + "," + Offset + "," + Limit + "," + 0 + "," + 0 + "," + getLogin().getUserName());
                listN100 = customerInf.getListCustomer_PA(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

            } else if (getTypeSearch() == 5) {
                flags = 5;
                listN100 = customerInf.getListCustomer_MA(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

            } else if (getTypeSearch() == 7) {
                flags = 7;
                listN100 = customerInf.getListCustomer_MA(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

            } else if (getTypeSearch() == 100) {
                flags = 100;
                System.out.println("tìm kiếm-------------------------STUA-----------");

                if (SessionProvider.getSessionMapValue("IDFK300STATUS") != null) {
                    FK330 = Util.parseInt(SessionProvider.getSessionMapValue("IDFK300STATUS"));
                }
                System.out.println("------THAM SO TIM KIEM-----------------" + getLogin().getModule() + "," + getLogin().getCompanyNo() + "," + pn100 + "," + ni104 + "," + FK330 + "," + Util.toSQLDate(startDateSta) + "," + Util.toSQLDate(endDateSta) + "," + Offset + "," + Limit + "," + 0 + "," + 0 + "," + getLogin().getUserName());
                listN100 = customerInf.LISTOFTABN100STA(getLogin().getModule(), getLogin().getCompanyNo(), pn100, ni104, FK330, Util.toSQLDate(startDateSta), Util.toSQLDate(endDateSta), Offset, Limit, 0, 0, getLogin().getUserName());

            }else if (getTypeSearch() == 200) {
                flags = 200;
                System.out.println("tìm kiếm--------------KHI ENTER----------");

               

            } else if (getTypeSearch() == 0) {
                flags = 0;
                if (getLogin().getCharacter() != null) {
                    flag1 = 1;
                    System.out.println("kkkkkkkkkkkkkkkkkkkkkkkkk22222222" + keySearch + getLogin().getCharacter());
                    listN100 = customerInf.getListCustomer(getLogin().getModule(), getLogin().getCompanyNo(), 2, getGroupID(), this.pn100, getLogin().getCharacter(), ni104, Offset, Limit, 0, 0, getLogin().getUserName());

                } else if (groupID != 0) {
                    flag1 = 2;


                    listN100 = customerInf.getListCustomer(getLogin().getModule(), getLogin().getCompanyNo(), 2, getGroupID(), this.pn100, getLogin().getCharacter(), ni104, Offset, Limit, 0, 0, getLogin().getUserName());


                } else {
                    if (idmobiSAVE != 0) {
                        System.out.println("---------------NGAY THANG LOAD---------DDDDDD------------------" + getLogin().getModule() + "," + getLogin().getCompanyNo() + "," + 0 + "," + Util.toSQLDate(dateStatus) + "," + Util.toSQLDate(endDateSta) + "," + Offset + "," + Limit + "," + 0 + "," + 0 + "," + userAction);
                        listN100 = customerInf.getReport_listoftabN100(getLogin().getModule(), getLogin().getCompanyNo(), 0, Util.toSQLDate(dateStatus), Util.toSQLDate(endDateSta), Offset, Limit, 0, 0, userAction);

                    } else {
                        flag1 = 3;
                        System.out.println("List default" + keySearch + getLogin().getCharacter() + ni104);
                        if (keySearch == null && getDayss() == 0) {
                            flag2 = 1;
                            System.out.println("--------HAM CHAY VAO CUSTOMER---------" + getLogin().getModule() + "," + getLogin().getCompanyNo() + "," + this.getPn100() + "," + this.ni104 + "," + keySearch + "," + Offset + "," + Limit + "," + 0 + "," + 0 + "," + userAction);
                            listN100 = customerInf.getListCustomerALL(getLogin().getModule(), getLogin().getCompanyNo(), this.getPn100(), this.ni104, keySearch, Offset, Limit, 0, 0, userAction);
                        } else if (getDayss() != 0) {
                            flag2 = 2;
                            System.out.println("List2---------loginEmp--" + loginEmp + "--userAction--" + userAction);
                            listN100 = customerInf.getListCustomerLDAYS(getLogin().getModule(), getLogin().getCompanyNo(), getDayss(), Offset, Limit, 0, 0, userAction);
                        } else {
                            flag2 = 3;
                            if(pagename.equals("ALL")){
                               System.out.println("List3----------loginEmp--" + getLogin().getModule()+","+ getLogin().getCompanyNo()+","+ this.getPn100()+","+ getGroupID()+","+ 0+","+ keySearch+","+ Offset+","+ Limit+","+ 0+","+ 0+","+ getLogin().getUserName());
                            listN100 = customerInf.getListCustomerALL1(getLogin().getModule(), getLogin().getCompanyNo(), this.getPn100(), getGroupID(), 0, keySearch, Offset, Limit, 0, 0, getLogin().getUserName()); 
                            }                           
                        }
                    }
                }
            }

            System.out.println("---BAT DAU- LAY ROW VE PHAN TRANG-------" + listN100.size());
            if (listN100.size() > 0) {
                SessionProvider.setSessionMapValue("LISTN100CUSSS", listN100);
            }
            if (Offset == 0) {
                if (listN100.size() > 0) {
                    n100 = listN100.get(0);
                    if (n100 != null) {
                       
                            SessionProvider.setSessionMapValue("totalcurent", n100.getRowss());
                       
                        //totalcurent = n100.getRowss();
                    } else {
                        SessionProvider.setSessionMapValue("totalcurent", 0);
                        //totalcurent = 0;
                    }
                } else {
                    SessionProvider.setSessionMapValue("totalcurent", 0);
                    //totalcurent = 0;
                }
            }

        } catch (Exception ex) {
            System.out.println("----------->>>>-+error" + ex.getMessage());
            return null;
        }
        if (listN100 == null) {
            listN100 = new ArrayList<N100>();
        }

        //paging
        int t;
        Object obj = SessionProvider.getSessionMapValue("totalcurent");
        if (obj != null) {
            try {
                t = Integer.parseInt(obj.toString());
            } catch (Exception e) {
                t = 0;
            }
            totalcurent = t;
        } else {
            totalcurent = 0;
        }

        setTotalrow(totalcurent);

        //Duy sms
        List<N100> list = new ArrayList<N100>();
        if (flags == 1) {
            list = customerInf.getListCustomer_COMPANY(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

        } else if (flags == 2) {
            list = customerInf.getListCustomer_MO(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

        } else if (flags == 3) {
            list = customerInf.getListCustomer_NA(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

        } else if (flags == 4) {
            list = customerInf.getListCustomer_PA(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

        } else if (flags == 5) {
            list = customerInf.getListCustomer_MA(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

        } else if (flags == 7) {
            list = customerInf.getListCustomer_MA(getLogin().getModule(), getLogin().getCompanyNo(), keySearch, Offset, Limit, 0, 0, getLogin().getUserName());

        } else if (flags == 0) {
            flags = 0;
            if (flag1 == 1) {
                list = customerInf.getListCustomer(getLogin().getModule(), getLogin().getCompanyNo(), 2, getGroupID(), this.pn100, getLogin().getCharacter(), ni104, Offset, Limit, 0, 0, getLogin().getUserName());

            } else if (flag1 == 2) {
                flag1 = 2;
                list = customerInf.getListCustomer(getLogin().getModule(), getLogin().getCompanyNo(), 2, getGroupID(), this.pn100, getLogin().getCharacter(), ni104, Offset, Limit, 0, 0, getLogin().getUserName());

            } else if (flag1 == 3) {
                flag1 = 3;
                if (flag2 == 1) {
                    list = customerInf.getListCustomerALL(getLogin().getModule(), getLogin().getCompanyNo(), this.getPn100(), this.ni104, keySearch, Offset, Limit, 0, 0, getLogin().getUserName());
                } else if (flag2 == 2) {
                    list = customerInf.getListCustomerLDAYS(getLogin().getModule(), getLogin().getCompanyNo(), getDayss(), 0, 100, 0, 1, getLogin().getUserName());
                } else if (flag2 == 3) {
                    list = customerInf.getListCustomerALL1(getLogin().getModule(), getLogin().getCompanyNo(), this.getPn100(), getGroupID(), this.ni104, keySearch, Offset, Limit, 0, 0, getLogin().getUserName());
                }

            }
        }
        SessionProvider.setSessionMapValue("ListSMSCustomer", list);

        return listN100;

    }

    public void reloadDAYS() {
        try {
            String dateStart = ContextUtil.getRequestParameter("leavedate1a");
            String dateStart1 = ContextUtil.getRequestParameter("leavedate1b");
            sendRedirectUrlTab("customer.jsp?action=reloadfordays1&dayID=" + 1 + "&startDTD=" + dateStart + "&endDTD=" + dateStart1);
        } catch (Exception e) {
        }
    }

// onchange status
    public void reloadStatus() {
        try {
            SessionProvider.setSessionMapValue("typeSearch", 100);
            String dateStart = ContextUtil.getRequestParameter("leavedate111");
            if (dateStart != null) {
                setStartDateSta(Util.parseDate(dateStart, "dd/MM/yyyy"));
            } else {
                // setNd118(null);
            }
            String dateStart1 = ContextUtil.getRequestParameter("leavedate112");

            if (dateStart != null) {
                setEndDateSta(Util.parseDate(dateStart1, "dd/MM/yyyy"));

            } else {
                // setNd118(null);
            }
            System.out.println("------NGÀY THÁNG-------" + startDateSta + endDateSta);
        } catch (Exception e) {
        }
    }

    public void reloadStatus1() {
        try {
            SessionProvider.setSessionMapValue("typeSearch", 101);
            String dateStart = ContextUtil.getRequestParameter("leavedate111");

            if (dateStart != null) {
                setStartDateSta(Util.parseDate(dateStart, "dd/MM/yyyy"));

            } else {
                // setNd118(null);
            }
            String dateStart1 = ContextUtil.getRequestParameter("leavedate112");

            if (dateStart != null) {
                setEndDateSta(Util.parseDate(dateStart1, "dd/MM/yyyy"));

            } else {
                // setNd118(null);
            }
            System.out.println("------NGÀY THÁNG-------" + startDateSta + endDateSta);
        } catch (Exception e) {
        }
    }

    // onchange sinh nhat
    public void reloadStatusBr() {
        try {


            String dateStart = ContextUtil.getRequestParameter("leavedate1112");

            if (dateStart != null) {
                setStartDateSta(Util.parseDate(dateStart, "dd/MM/yyyy"));

            } else {
                // setNd118(null);
            }
            String dateStart1 = ContextUtil.getRequestParameter("leavedate1122");

            if (dateStart != null) {
                setEndDateSta(Util.parseDate(dateStart1, "dd/MM/yyyy"));

            } else {
                // setNd118(null);
            }
            System.out.println("------NGÀY THÁNG-------" + startDateSta + endDateSta);
        } catch (Exception e) {
        }
    }

    public void reloadlist(ActionEvent ac) {
        SessionProvider.setSessionMapValue("emp", loginEmp);
        userAction = loginEmp;
        setDayss(0);
        SessionProvider.setSessionMapValue("typeSearch", 0);
        SessionProvider.setSessionMapValue("keySearch", null);
        sendRedirect("customer.jsp");

    }

    public void reload() {
        try {
            SessionProvider.setSessionMapValue("submitSearch", "false");
            SessionProvider.setSessionMapValue("typeSearch", typeSearch);
            SessionProvider.setSessionMapValue("keySearch", keySearch);
             System.out.println("------KHI CLICK VAO TIM KIEM CUA KH CA NHAN---" + typeSearch + "-------KEY---" + keySearch);
            sendRedirectUrlTab("customer.jsp?action=functionSearch&keysearch=" + keySearch + "&typesearch=" + typeSearch);
        } catch (Exception e) {
        }

    }

    public void searchAlphaCustomer() {
        try {
            if (ContextUtil.getRequestParameter("idSearch") != null) {
                if (getLogin().getCharacter() != null || ContextUtil.getRequestParameter("idSearch").toString().equals(getLogin().getCharacter())) {
                    setTypeSearch(0);
                    setKeySearch(ContextUtil.getRequestParameter("idSearch").toString());

                    SessionProvider.setSessionMapValue("submitSearch", "true");
                } else {
                    setTypeSearch(0);
                    SessionProvider.setSessionMapValue("submitSearch", "false");
                }
            }
            setIdSearch(ContextUtil.getRequestParameter("idSearch"));
            if (getIdSearch() != null && getIdSearch().contains("ALL")) {
                setIdSearch(null);
                getLogin().setCharacter(getIdSearch());
            } else if (getIdSearch() == null) {
                getLogin().setCharacter(getIdSearch());
            } else {
                getLogin().setCharacter(getIdSearch());
            }

        } catch (Exception ex) {
            setIdSearch("ALL");
        }

    }

    /**
     * @return the listGroup
     */
    public List<SelectItem> getListGroup() {
        listGroup = comboboxUtil.getListCombK400F("N100C");
        return listGroup;
    }

    /**
     * @param listGroup the listGroup to set
     */
    public void setListGroup(List<SelectItem> listGroup) {
        this.listGroup = listGroup;
    }

    /**
     * @return the groupID
     */
    public int getGroupID() {
        if (SessionProvider.getSessionMapValue("groupcustomerID") == null) {
            SessionProvider.setSessionMapValue("groupcustomerID", 0);
        } else {
            groupID = Integer.parseInt(SessionProvider.getSessionMapValue("groupcustomerID").toString());
        }

        return groupID;
    }

    /**
     * @param groupID the groupID to set
     */
    public void setGroupID(int groupID) {
        this.groupID = groupID;
    }

    /**
     * @return the typeSearch
     */
    public int getTypeSearch() {
        if (SessionProvider.getSessionMapValue("typeSearch") != null) {
            typeSearch = Util.parseInt(SessionProvider.getSessionMapValue("typeSearch"));
        }
        return typeSearch;
    }

    /**
     * @param typeSearch the typeSearch to set
     */
    public void setTypeSearch(int typeSearch) {
        this.typeSearch = typeSearch;
    }

    /**
     * @return the keySearch
     */
    public String getKeySearch() {
        return keySearch;
    }

    /**
     * @param keySearch the keySearch to set
     */
    public void setKeySearch(String keySearch) {
        this.keySearch = keySearch;
    }

    /**
     * @return the listQ400
     */
    public List<Q400> getListQ400() {
        return listQ400;
    }

    /**
     * @param listQ400 the listQ400 to set
     */
    public void setListQ400(List<Q400> listQ400) {
        this.listQ400 = listQ400;
    }

    /**
     * @return the nv127
     */
    public String getNv127() {
        return nv127;
    }

    /**
     * @param nv127 the nv127 to set
     */
    public void setNv127(String nv127) {
        this.nv127 = nv127;
    }

    /**
     * @return the messagefrom
     */
    public String getMessagefrom() {
        return messagefrom;
    }

    /**
     * @param messagefrom the messagefrom to set
     */
    public void setMessagefrom(String messagefrom) {
        this.messagefrom = messagefrom;
    }

    /**
     * @return the message
     */
    public String getMessage() {
        return message;
    }

    /**
     * @param message the message to set
     */
    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * @return the editpage
     */
    public String getEditpage() {
        return editpage;
    }

    /**
     * @param editpage the editpage to set
     */
    public void setEditpage(String editpage) {
        this.editpage = editpage;
    }

    public void submitform(ActionEvent evt) {
        System.out.println("----------demo----valieate -----------");
    }

    /**
     * @return the nv129
     */
    public String getNv129() {
        return nv129;
    }

    /**
     * @param nv129 the nv129 to set
     */
    public void setNv129(String nv129) {
        this.nv129 = nv129;
    }

    /**
     * @return the nv130
     */
    public String getNv130() {
        return nv130;
    }

    /**
     * @param nv130 the nv130 to set
     */
    public void setNv130(String nv130) {
        this.nv130 = nv130;
    }

    /**
     * @return the listComboK300
     */
    public List<SelectItem> getListComboK300() {
        ComboboxUtil com = new ComboboxUtil();
        listComboK300 = com.getlistCombK300("K");
        return listComboK300;
    }

    /**
     * @param listComboK300 the listComboK300 to set
     */
    public void setListComboK300(List<SelectItem> listComboK300) {
        this.listComboK300 = listComboK300;
    }

    /**
     * @return the listComboK350
     */
    public List<SelectItem> getListComboK330() {
        ComboboxUtil com = new ComboboxUtil();
        listComboK330 = com.getlistCombK330("K");
        return listComboK330;
    }

    /**
     * @param listComboK350 the listComboK350 to set
     */
    public void setListComboK330(List<SelectItem> listComboK330) {
        this.listComboK330 = listComboK330;
    }

    /**
     * @return the FK300
     */
    public int getFK300() {
        return FK300;
    }

    /**
     * @param FK300 the FK300 to set
     */
    public void setFK300(int FK300) {
        this.FK300 = FK300;
    }

    /**
     * @return the FK350
     */
    public int getFK330() {
        return FK330;
    }

    /**
     * @param FK350 the FK350 to set
     */
    public void setFK330(int FK330) {
        this.FK330 = FK330;
    }

    /**
     * @return the Offset
     */
    public int getOffset() {
        return Offset;
    }

    /**
     * @param Offset the Offset to set
     */
    public void setOffset(int Offset) {
        this.Offset = Offset;
    }

    /**
     * @return the Limit
     */
    public int getLimit() {
        return Limit;
    }

    /**
     * @param Limit the Limit to set
     */
    public void setLimit(int Limit) {
        this.Limit = Limit;
    }

    // property for paging
    /**
     * @return the current
     */
    public int getCurrent() {
        if (current > totalpage) {
            current = totalpage;
        } else if (current < 1) {
            current = 1;
        }
        return current;
    }

    /**
     * @param current the current to set
     */
    public void setCurrent(int current) {

        start = (current - 1) * getNumrow();
        end = current * numrow;
        this.current = current;
    }

    /**
     * @return the numrow
     */
    public int getNumrow() {
        if (numrow == 0) {
            numrow = 30;
        }
        return numrow;
    }

    /**
     * @param numrow the numrow to set
     */
    public void setNumrow(int numrow) {
        this.numrow = numrow;
    }

    /**
     * @return the start
     */
    public int getStart() {
        if (start == 0) {
            start = 1;
        }
        return start;
    }

    /**
     * @param start the start to set
     */
    public void setStart(int start) {
        this.start = start;
    }

    /**
     * @return the end
     */
    public int getEnd() {
        if (end == 0) {
            end = 20;
        }
        return end;
    }

    /**
     * @param end the end to set
     */
    public void setEnd(int end) {
        this.end = end;
    }

    /**
     * @return the totalrow
     */
    public int getTotalrow() {
        return totalrow;
    }

    /**
     * @param totalrow the totalrow to set
     */
    public void setTotalrow(int totalrow) {
//        if (totalrow == 0) {
//            totalrow = 100;
//        }
        totalpage = totalrow / numrow;

        if (totalrow % numrow > 0) {
            totalpage = totalpage + 1;
        }


        if (getTotalpage() <= 10) {
            setStartpage(1);
            setEndpage(getTotalpage());

        } else {
            setStartpage(current - 5);
            setEndpage(current + 5);


        }
        this.totalrow = totalrow;
    }

    /**
     * @return the startpage
     */
    public int getStartpage() {
        if (startpage < 1) {
            startpage = 1;
        }
        return startpage;
    }

    /**
     * @param startpage the startpage to set
     */
    public void setStartpage(int startpage) {
        this.startpage = startpage;
    }

    /**
     * @return the endpage
     */
    public int getEndpage() {
        if (endpage > totalpage) {
            endpage = totalpage;
        }
        return endpage;
    }

    /**
     * @param endpage the endpage to set
     */
    public void setEndpage(int endpage) {

        this.endpage = endpage;
    }

    /**
     * @return the totalpage
     */
    public int getTotalpage() {
//        if (totalpage == 0) {
//            totalpage = 10;
//        }
        return totalpage;
    }

    /**
     * @param totalpage the totalpage to set
     */
    public void setTotalpage(int totalpage) {
        this.totalpage = totalpage;
    }

    /**
     * @return the pagename
     */
    public String getPagename() {
        return pagename;
    }

    /**
     * @param pagename the pagename to set
     */
    public void setPagename(String pagename) {
        this.pagename = pagename;
    }

    /**
     * @return the totalcurent
     */
    public int getTotalcurent() {
        return totalcurent;
    }

    /**
     * @param totalcurent the totalcurent to set
     */
    public void setTotalcurent(int totalcurent) {
        this.totalcurent = totalcurent;
    }

    /**
     * @return the typesearchcurent
     */
    public int getTypesearchcurent() {
        return typesearchcurent;
    }

    /**
     * @param typesearchcurent the typesearchcurent to set
     */
    public void setTypesearchcurent(int typesearchcurent) {
        this.typesearchcurent = typesearchcurent;
    }

    /**
     * @return the tip
     */
    public int getTip() {
        return tip;
    }

    /**
     * @param tip the tip to set
     */
    public void setTip(int tip) {
        this.tip = tip;
    }

    /**
     * @return the nv961
     */
    public String getNv961() {
        return nv961;
    }

    /**
     * @param nv961 the nv961 to set
     */
    public void setNv961(String nv961) {
        this.nv961 = nv961;
    }

    /**
     * @return the hoten
     */
    public String getHoten() {
        return hoten;
    }

    /**
     * @param hoten the hoten to set
     */
    public void setHoten(String hoten) {
        this.hoten = hoten;
    }

    /**
     * @return the choisetab
     */
    public int getChoisetab() {
        return choisetab;
    }

    /**
     * @param choisetab the choisetab to set
     */
    public void setChoisetab(int choisetab) {
        this.choisetab = choisetab;
    }

    /**
     * @return the mv036
     */
    public String getMv306() {
        return mv306;
    }

    /**
     * @param mv036 the mv036 to set
     */
    public void setMv306(String mv306) {
        this.mv306 = mv306;
    }

    /**
     * @return the urlMD5
     */
    public String getUrlMD5() {
        return urlMD5;
    }

    /**
     * @param urlMD5 the urlMD5 to set
     */
    public void setUrlMD5(String urlMD5) {
        this.urlMD5 = urlMD5;
    }

    /**
     * @return the empString
     */
    public String getEmpString() {
        return empString;
    }

    /**
     * @param empString the empString to set
     */
    public void setEmpString(String empString) {
        this.empString = empString;
    }

    /**
     * @return the keysearchKH
     */
    public String getKeysearchKH() {
        return keysearchKH;
    }

    /**
     * @param keysearchKH the keysearchKH to set
     */
    public void setKeysearchKH(String keysearchKH) {
        this.keysearchKH = keysearchKH;
    }

    /**
     * @return the typesearchKH
     */
    public int getTypesearchKH() {
        return typesearchKH;
    }

    /**
     * @param typesearchKH the typesearchKH to set
     */
    public void setTypesearchKH(int typesearchKH) {
        this.typesearchKH = typesearchKH;
    }

    /**
     * @param listdifn100 the listdifn100 to set
     */
    public void setListdifn100(List<N100> listdifn100) {
        this.listdifn100 = listdifn100;
    }

    /**
     * @return the list
     */
    public List<N100> getList() {
        return list;
    }

    /**
     * @param list the list to set
     */
    public void setList(List<N100> list) {
        this.list = list;
    }

    /**
     * @return the tel
     */
    public String getTel() {
        return tel;
    }

    /**
     * @param tel the tel to set
     */
    public void setTel(String tel) {
        this.tel = tel;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @return the mobi
     */
    public String getMobi() {
        return mobi;
    }

    /**
     * @param mobi the mobi to set
     */
    public void setMobi(String mobi) {
        this.mobi = mobi;
    }

    /**
     * @return the notice
     */
    public String getNotice() {
        return notice;
    }

    /**
     * @param notice the notice to set
     */
    public void setNotice(String notice) {
        this.notice = notice;
    }

    /**
     * @return the listCustomerForDay
     */
    public List<N100> getListCustomerForDay() {
        try {
            System.out.println("--------------" + getLogin().getModule() + "," + getLogin().getCompanyNo() + "," + dayss + "," + 0 + "," + 100 + "," + 0 + "," + 1 + "," + getLogin().getUserName());
            listCustomerForDay = customerInf.getListCustomerLDAYS(getLogin().getModule(), getLogin().getCompanyNo(), getDayss(), 0, 100, 0, 1, getLogin().getUserName());
            System.out.println("--------LIST DAYSS------" + listCustomerForDay.size());
            return listCustomerForDay;
        } catch (Exception ex) {
            return null;
        }

    }

    /**
     * @param listCustomerForDay the listCustomerForDay to set
     */
    public void setListCustomerForDay(List<N100> listCustomerForDay) {
        this.listCustomerForDay = listCustomerForDay;
    }

    /**
     * @return the dayss
     */
    public int getDayss() {
        return dayss;
    }

    /**
     * @param dayss the dayss to set
     */
    public void setDayss(int dayss) {
        this.dayss = dayss;
    }

    /**
     * @return the fk400
     */
    public int getFk400() {
        return fk400;
    }

    /**
     * @param fk400 the fk400 to set
     */
    public void setFk400(int fk400) {
        this.fk400 = fk400;
    }

    /**
     * @return the flagForm
     */
    public int getFlagForm() {
        return flagForm;
    }

    /**
     * @param flagForm the flagForm to set
     */
    public void setFlagForm(int flagForm) {
        this.flagForm = flagForm;
    }

    /**
     * @return the lstEmpByID
     */
    public List<SelectItem> getLstEmpByID() {
        String emp = loginEmp;
        try {
            if (lstEmpByID == null || lstEmpByID.size() < 1) {
                lstEmpByID = comboboxUtil.getSelectedN900Comb(fn850);
                for (int i = 0; i < lstEmpByID.size(); i++) {
                    if (lstEmpByID.get(i).getValue().toString().equals(loginEmp)) {
                        //neu nhan vien dc chon co trong nhom to
                        emp = lstEmpByID.get(i).getValue().toString();
                        break;
                    } else {//neu ko co thi gan la ng dau tien
                        emp = lstEmpByID.get(0).getValue().toString();
                    }
                }
                loginEmp = emp;
                if (flagFN850 == 10) {
                    userAction = emp;
                }
                SessionProvider.setSessionMapValue("emp", loginEmp);
            }

        } catch (Exception e) {
            System.out.println("getLstEmpByID error--:" + e.getMessage());
            lstEmpByID = new ArrayList<SelectItem>();
        }

        System.out.println("getLstEmpByID-size-" + lstEmpByID.size() + "---fn850--" + fn850 + "--emplogin--" + loginEmp);
        return lstEmpByID;
    }

    /**
     * @param lstEmpByID the lstEmpByID to set
     */
    public void setLstEmpByID(List<SelectItem> lstEmpByID) {
        this.lstEmpByID = lstEmpByID;
    }

    /**
     * @return the loginEmp
     */
    public String getLoginEmp() {
        return loginEmp;
    }

    /**
     * @param loginEmp the loginEmp to set
     */
    public void setLoginEmp(String loginEmp) {
        this.loginEmp = loginEmp;
    }

    public Boolean checkExistList(List<N100> list, int index) {
        for (N100 n100 : list) {
            if (n100.getPn100() == index) {
                return true;
            }
        }
        return false;
    }

    /**
     * @return the listSelectedNV
     */
    public List<N100> getListSelectedNV() {
        return listSelectedNV;
    }

    /**
     * @param listSelectedNV the listSelectedNV to set
     */
    public void setListSelectedNV(List<N100> listSelectedNV) {
        this.listSelectedNV = listSelectedNV;
    }

    /**
     * @return the listSelectedDD
     */
    public List<N100> getListSelectedDD() {
        return listSelectedDD;
    }

    /**
     * @param listSelectedDD the listSelectedDD to set
     */
    public void setListSelectedDD(List<N100> listSelectedDD) {
        this.listSelectedDD = listSelectedDD;
    }

    /**
     * @return the listSelectedNVout
     */
    public List<N100> getListSelectedNVout() {
        return listSelectedNVout;
    }

    /**
     * @param listSelectedNVout the listSelectedNVout to set
     */
    public void setListSelectedNVout(List<N100> listSelectedNVout) {
        this.listSelectedNVout = listSelectedNVout;
    }

    /**
     * @return the listSelectedDDout
     */
    public List<N100> getListSelectedDDout() {
        return listSelectedDDout;
    }

    /**
     * @param listSelectedDDout the listSelectedDDout to set
     */
    public void setListSelectedDDout(List<N100> listSelectedDDout) {
        this.listSelectedDDout = listSelectedDDout;
    }

    /**
     * @return the idListTour
     */
    public int getIdListTour() {
        return idListTour;
    }

    /**
     * @param idListTour the idListTour to set
     */
    public void setIdListTour(int idListTour) {
        this.idListTour = idListTour;
    }

    /**
     * @return the chooseformepmloyee
     */
    public int getChooseformepmloyee() {
        return chooseformepmloyee;
    }

    /**
     * @param chooseformepmloyee the chooseformepmloyee to set
     */
    public void setChooseformepmloyee(int chooseformepmloyee) {
        this.chooseformepmloyee = chooseformepmloyee;
    }

    /**
     * @return the FV050EE
     */
    public int getFV050EE() {
        return FV050EE;
    }

    /**
     * @param FV050EE the FV050EE to set
     */
    public void setFV050EE(int FV050EE) {
        this.FV050EE = FV050EE;
    }

    /**
     * @return the nv123
     */
    public String getNv123() {
        return nv123;
    }

    /**
     * @param nv123 the nv123 to set
     */
    public void setNv123(String nv123) {
        this.nv123 = nv123;
    }

    /**
     * @return the close
     */
    public int getClose() {
        return close;
    }

    /**
     * @param close the close to set
     */
    public void setClose(int close) {
        this.close = close;
    }

    /**
     * @return the startDateSta
     */
    public Date getStartDateSta() {
        return startDateSta;
    }

    /**
     * @param startDateSta the startDateSta to set
     */
    public void setStartDateSta(Date startDateSta) {
        this.startDateSta = startDateSta;
    }

    /**
     * @return the endDateSta
     */
    public Date getEndDateSta() {
        return endDateSta;
    }

    /**
     * @param endDateSta the endDateSta to set
     */
    public void setEndDateSta(Date endDateSta) {
        this.endDateSta = endDateSta;
    }

    /**
     * @return the dateStatus
     */
    public Date getDateStatus() {
        return dateStatus;
    }

    /**
     * @param dateStatus the dateStatus to set
     */
    public void setDateStatus(Date dateStatus) {
        this.dateStatus = dateStatus;
    }

    /**
     * @return the idmobiSAVE
     */
    public int getIdmobiSAVE() {
        return idmobiSAVE;
    }

    /**
     * @param idmobiSAVE the idmobiSAVE to set
     */
    public void setIdmobiSAVE(int idmobiSAVE) {
        this.idmobiSAVE = idmobiSAVE;
    }

    /**
     * @return the passwordSMS
     */
    public int getPasswordSMS() {
        return passwordSMS;
    }

    /**
     * @param passwordSMS the passwordSMS to set
     */
    public void setPasswordSMS(int passwordSMS) {
        this.passwordSMS = passwordSMS;
    }

    public void chooseTabll() {
        try {
            setTabString("TABLL");
            SessionProvider.setSessionMapValue("TABLL1", tabString);
            listSelected.clear();
//            if (SessionProvider.getSessionMapValue("listSelectedEx") != null) {
//                 SessionProvider.setSessionMapValue("listSelectedEx",null);
//             }
//             if(SessionProvider.getSessionMapValue("listN100") != null){
//                 SessionProvider.setSessionMapValue("listN100", null);
//             }

        } catch (Exception e) {
        }
    }

    public void chooseTabNV() {
        try {
            setTabString("TABNV");
            SessionProvider.setSessionMapValue("TABLL1", tabString);
//            listN500DB  = (List<N500>) SessionProvider.getSessionMapValue("listN500");
//            setTabString("TABCN");
            listSelected.clear();
            if (SessionProvider.getSessionMapValue("listSelectedEx") != null) {
                SessionProvider.setSessionMapValue("listSelectedEx", null);
            }
            if (SessionProvider.getSessionMapValue("listN100") != null) {
                SessionProvider.setSessionMapValue("listN100", null);
            }
        } catch (Exception e) {
        }
    }

    public void chooseTabTK() {
        try {
            setTabString("TABTK");
            SessionProvider.setSessionMapValue("TABLL1", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabTL() {
        try {
            setTabString("TABTL");
            SessionProvider.setSessionMapValue("TABLL1", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabLSKH() {
        try {
            setTabString("TABLSKH");
            SessionProvider.setSessionMapValue("TABLL1", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabLST() {
        try {
            setTabString("TABLST");
            SessionProvider.setSessionMapValue("TABLL1", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabLSCN() {
        try {
            setTabString("TABLSCN");
            SessionProvider.setSessionMapValue("TABLL1", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabLSNT() {
        try {
            setTabString("TABLSNT");
            SessionProvider.setSessionMapValue("TABLL1", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabCM() {
        try {
            setTabString("TABCM");
            SessionProvider.setSessionMapValue("TABLL1", tabString);
        } catch (Exception e) {
        }
    }

    /**
     * @return the tabString
     */
    public String getTabString() {
        if (SessionProvider.getSessionMapValue("TABLL1") != null) {
            tabString = SessionProvider.getSessionMapValue("TABLL1").toString();
        } else {
        }
        return tabString;
    }

    /**
     * @param tabString the tabString to set
     */
    public void setTabString(String tabString) {
        this.tabString = tabString;
    }

    /**
     * @return the fk100down
     */
    public int getFk100down() {
        if (SessionProvider.getSessionMapValue("PN100HD") != null) {
            fk100down = Util.parseInt(SessionProvider.getSessionMapValue("PN100HD"));
        }
        return fk100down;
    }

    /**
     * @param fk100down the fk100down to set
     */
    public void setFk100down(int fk100down) {
        this.fk100down = fk100down;
    }

    public void reloadfordata() {
        try {
            String dateStart = null;
            String dateEnd = null;
            if (!Util.toSQLDate(dateStatus).toString().equals("")) {
                dateStart = Util.toSQLDate(dateStatus).toString().substring(8, 10) + "/" + Util.toSQLDate(dateStatus).toString().substring(5, 7) + "/" + Util.toSQLDate(dateStatus).toString().substring(0, 4);;
            }
            if (!Util.toSQLDate(endDateSta).toString().equals("")) {
                dateEnd = Util.toSQLDate(endDateSta).toString().substring(8, 10) + "/" + Util.toSQLDate(endDateSta).toString().substring(5, 7) + "/" + Util.toSQLDate(endDateSta).toString().substring(0, 4);;
            }


            System.out.println(dateStart + "--------------DAYEEEEEEEEEEE-----------" + dateEnd);

            sendRedirectUrlTab("customer.jsp?action=reloadfordays1&dayID=" + 1 + "&startDTD=" + dateStart + "&endDTD=" + dateEnd);
        } catch (Exception e) {
        }
    }
}
